直接上代码
def translate(pop): #数据转换,二进制转十进制
a = pop.dot(2 ** np.arange(10)[::-1])
print("二进制为"+str(pop))
print("转化为十进制是:"+str(a))
pop = np.random.randint(2, size=(1, 10))
print(pop)
translate(pop)
原文:https://www.cnblogs.com/lijiahaoAA/p/14654793.html