2024-04-25 03:33:29 发布
网友
我有一个4bytes的array,我需要将它的值打印为Integer。这在C语言中非常简单,因为我可以使用以下内容进行投射和打印:
bytes
array
Integer
printf("Integer Value = %i", (int) pointer_to_4_bytes_array);
谢谢。在
在Python2(也适用于3)中,可以使用^{}模块。在
>>> import struct >>> struct.unpack(">L","1234")[0] 825373492
在Python3.2+中,^{}可以随心所欲。看@ryrich的答案
我相信你在找int.from_bytes
注意:对于Python3.2
如果您在Python 3.2+上有一个函数:
int.from_bytes()
对于python2,可以使用struct。在
在Python2(也适用于3)中,可以使用^{} 模块。在
在Python3.2+中,^{} 可以随心所欲。看@ryrich的答案
^{pr2}$我相信你在找int.from_bytes
注意:对于Python3.2
如果您在Python 3.2+上有一个函数:
对于python2,可以使用struct。在
相关问题 更多 >
编程相关推荐