ValueError:未知的格式代码';x';对于类型为'的对象;str';在python 2中
我有此错误ValueError:未知的格式代码';x';对于类型为'的对象;str';在python 2中,python,Python,我有此错误ValueError:类型为“str”的对象的未知格式代码“x”。 问题是我的python版本(Python2.7),但我无法升级它。 有人知道如何在Python2中执行这行代码。 map('{:02x}'.format, bytes_addr) 输出 Traceback (most recent call last): File "basic_sniff1.py", line 80, in <module> main() File "basic_sniff
ValueError:类型为“str”的对象的未知格式代码“x”
。
问题是我的python版本(Python2.7),但我无法升级它。
有人知道如何在Python2中执行这行代码。
map('{:02x}'.format, bytes_addr)
输出
Traceback (most recent call last):
File "basic_sniff1.py", line 80, in <module>
main()
File "basic_sniff1.py", line 54, in main
eth = ethernet_head(raw_data)
File "basic_sniff1.py", line 23, in ethernet_head
dest_mac = get_mac_addr(dest)
File "basic_sniff1.py", line 6, in get_mac_addr
byte_str = map('{:02x}'.format, mac_raw)
ValueError: Unknown format code 'x' for object of type 'str'
回溯(最近一次呼叫最后一次):
文件“basic_sniff1.py”,第80行,在
main()
文件“basic_sniff1.py”,第54行,主
eth=以太网头(原始数据)
文件“basic_sniff1.py”,第23行,以太网头
dest\u mac=get\u mac\u addr(dest)
文件“basic_sniff1.py”,第6行,在get_mac_addr中
byte_str=map('{:02x}'。格式,mac_原始)
ValueError:类型为“str”的对象的格式代码“x”未知
这是否回答了您的问题?谢谢我试过了,但不适合我,我不知道如何适应我的两个功能谢谢!我试过了,但对我不起作用,我不明白,如何使他的答案适应我的两个功能。因为我的函数至少接收两个参数…解决方案是python 3
Traceback (most recent call last):
File "basic_sniff1.py", line 80, in <module>
main()
File "basic_sniff1.py", line 54, in main
eth = ethernet_head(raw_data)
File "basic_sniff1.py", line 23, in ethernet_head
dest_mac = get_mac_addr(dest)
File "basic_sniff1.py", line 6, in get_mac_addr
byte_str = map('{:02x}'.format, mac_raw)
ValueError: Unknown format code 'x' for object of type 'str'