python读写bin文件
import numpy as np# 创建二进制数据
data = np.array([0x33, 0x34, 0x35, 0x36], dtype=np.uint8)# 写入bin文件
with open('example.bin', 'wb') as f:data.tofile(f)print("bin文件生成成功")data = np.fromfile('example.bin', dtype=np.uint8)
print("numpy读取结果:", data)
运行结果: