有什么办法可以将hexdump()保存到字节列表,以便可以通过索引访问列表。我需要的是这样
byte = hexdump(packet)
for i in range(0, len(byte)):
print %x byte[i]
可以通过调用来访问包的字节内容str(packet)
,如下所示:
content = str(packet) # decoded hex string, such as '\xde\xad\xbe\xef'
print content
for byte in content:
pass # do something with byte
编辑- 此答案指定如何将其转换为字节数组,例如:
byte_array = map(ord, str(packet)) # list of numbers, such as [0xDE, 0xAD, 0xBE, 0xEF]
print byte_array
for byte in byte_array:
pass # do something with byte
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句