Mar*_*ong 1 python struct module runtime-error
import struct
f = open('file.bin', 'wb')
value = 1.23456
data = struct.pack("f", value)
f.write(data)
f.close()
f = open('file.bin', 'rb')
print struct.unpack('f',f.read(4))
f.close()
Run Code Online (Sandbox Code Playgroud)
我尝试执行上面的代码,它给了我错误:
AttributeError:'module'对象没有属性'pack'
我使用的是python 2.7.5,我检查了模块列表,并且"struct"就在那里.