struct.unpack和win / lin中的python 2.4和2.4.4问题 [英] Problems with python 2.4 and 2.4.4 in struct.unpack and win/lin
本文介绍了struct.unpack和win / lin中的python 2.4和2.4.4问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用python 2.4在Linux debian机器上进行编码。
i'm coding on a Linux debian machine with python 2.4.
我的Windows XP和python 2.4.4邻居
My neighbour with Windows XP and python 2.4.4
他可以运行以下代码:
w1, w2, w3 = unpack("LLL", pack("LLHH", localtime, ipddr, counter, aid))
但是当我尝试此代码时,我成为错误:
But when i try this code i become this error:
w1, w2, w3 = unpack("LLL", pack("LLHH", localtime, ipddr, counter, aid))
struct.error: unpack str size does not match format
可以吗是python版本还是系统版本?
Can it be the Version of python or maybe the system?
推荐答案
使用 I
格式代码,而不是 L
。
Use the I
format code instead of L
.
在您的Linux机器上, L
的长度不是 H
的两倍,而是四倍,即8字节(64位)而不是4字节(32位)。
On your Linux machine, L
isn't twice as long as H
, it's four times as long -- 8 bytes (64 bits) instead of 4 bytes (32 bits).
I
两者都应为4字节(32位)。
I
should be 4 bytes (32 bits) on both.
编辑:请务必阅读eryksun的评论。
Make sure to read eryksun's comment.
这篇关于struct.unpack和win / lin中的python 2.4和2.4.4问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文