如何使用 Python 编写双精度文件二进制文件?我目前正在执行以下操作,但它给了我单精度文件:
#!/usr/bin/env python
import struct
data =[2.3715231753176,9.342983274982732]
output_file = "test.dat"
out_file = open(output_file,"wb")
s = struct.pack('f'*len(data), *data)
out_file.write(s)
out_file.close()