小编use*_*975的帖子

Python 3相当于Python 2 str.decode('hex')

我正在尝试将十六进制的IEEE 754浮点数转换为标准的python浮点数.

以下适用于Python 2.x:

foo ='4074145c00000005'
conv_pound = struct.unpack('!d', foo.decode('hex'))[0]
print(conv_pound)
Run Code Online (Sandbox Code Playgroud)

并产生以下输出(这确实是我想要的数字):

321.272460938
Run Code Online (Sandbox Code Playgroud)

但是,python 3没有str.decode方法,我很难找到如何做到这一点.有小费吗 ?

python decode python-2.7 python-3.x

6
推荐指数
1
解决办法
493
查看次数

标签 统计

decode ×1

python ×1

python-2.7 ×1

python-3.x ×1