with open('hehe.bin','wb') as file:
for i in range(10):
file.write(struct.pack("B",i))In [10]: import numpy as np
In [11]: np.fromfile("hehe.bin",dtype=np.int8)
Out[11]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int8)with open('hehe.bin','wb') as file:
for i in range(10):
file.write(struct.pack("B",i))In [10]: import numpy as np
In [11]: np.fromfile("hehe.bin",dtype=np.int8)
Out[11]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int8)
1658
6121

被折叠的 条评论
为什么被折叠?