我不明白为什么下面的代码答案是:
import numpy as np
dt=[('name','S16'),('grad',int),('cpg',float)]
val=[("Ahmadmm",2008,12),('ali',2010,12.2),('mitra',505,15.15)]
arr=np.array(val,dtype=dt)
print(arr)
output: [(b'Ahmadmm', 2008, 12. ) (b'ali', 2010, 12.2 ) (b'mitra', 505, 15.15)]
为什么每个字符串前都有一个“b”
正如NPE在本question中所述,引用Python 2.x documentation:
报告指出:
我想这篇文章回答了你的问题:What does the 'b' character do in front of a string literal?。“b”字符基本上表示字节文字
相关问题 更多 >
编程相关推荐