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)