在python中,代码如下
envimsg = struct.pack("!LHL", 1, 0, int(jsonmsg["flow_id"], 16)) + \
struct.pack("!HQH", 1, int(flow["src id"],16), 0) + \
struct.pack("!HQH", 1, int(flow["dst id"],16), int(flow["dst port"],16)) + \
struct.pack("!H", 0) + \
struct.pack("!HHHLL", int(jsonmsg["app_src_port"],10), int(jsonmsg["app_dst_port"],10), int(jsonmsg["app_proto"],10), int(jsonmsg["app_src_ip"],10), int(jsonmsg["app_dst_ip"],10))
排队
struct.pack("!H", 0) + \
我遇到这个错误:
File "./Translate_2503.py", line 205, in lavi2envi
struct.pack("!H", 0) + \
struct.error: integer out of range for 'L' format code
这很奇怪,因为我试着用H(无符号的短)。
有线索吗?
我的python版本2.7.3。 CPU archi是32位的。
最有可能的问题在于其中一项的价值:
即使在错误行指向此行时,错误也不在此处。在Python解释器中执行此指令不会产生错误:
这是有意义的,因为错误正在“L”格式代码上抱怨,所以错误将位于使用此格式的代码中。
假设“L”用于无符号long,并且消息抱怨超出范围,则错误是因为使用的一个(或多个)变量为负,从而产生无符号long的超出范围。
这可以在Python解释器中验证:
相关问题 更多 >
编程相关推荐