【发布时间】:2020-01-24 13:15:02
【问题描述】:
谁能告诉我如何读取结果 b'\x9a\x99\x99?的
import struct
data = struct.pack("@f", 1.2)
print(data)
\x9a 代表什么?还是\x99?如何将其翻译回1.2?
【问题讨论】:
标签: python python-3.x struct byte
谁能告诉我如何读取结果 b'\x9a\x99\x99?的
import struct
data = struct.pack("@f", 1.2)
print(data)
\x9a 代表什么?还是\x99?如何将其翻译回1.2?
【问题讨论】:
标签: python python-3.x struct byte
数据以二进制格式存储。要取回值,请使用struct.unpack:
import struct
data = struct.pack("@f",1.2)
print(struct.unpack("@f",data))
相关:Why won't Python display this text correctly? (UTF-8 Decoding Issue)
【讨论】: