我使用mapp方法从list(str)转到list(int),但是当我调用scapy库时。我没有得到相同的结果。
我使用的是python 2.7.13
print "E: {}".format(map(int, ['1', '2']))
返回
E: [1, 2]
和
from scapy.all import *
print "E: {}".format(map(int, ['1', '2']))
返回
E: <itertools.imap object at 0x0405E730
答案 0 :(得分:2)
在Python中将模块导入命名空间时,存在风险。
在这里,您使用的是Scapy的开发版本,这是一个错误(导入Scapy时,您不应导入Scapy的map()
,这是six
模块提供的版本。你应该report it。
但是,要避免这种情况,您应该在自己的命名空间中导入Scapy。例如:
from scapy import all as scapy
scapy.IP() / scapy.ICMP() # this will work
print "E: {}".format(map(int, ['1', '2'])) # this will display a list