[Python]写入二进制文件

版权声明:转载请说明Zhonglihao原创 https://blog.csdn.net/xeonmm1/article/details/86083259
import struct

with open(file_name_dir, 'wb')as fp:
   for x in data_pack:
        a = struct.pack('i', int(x))
        fp.write(a)
   fp.close()

pack的格式:

Python中struct.pack()åstruct.unpack()ç¨æ³è¯¦ç»è¯´æ

猜你喜欢

转载自blog.csdn.net/xeonmm1/article/details/86083259