简体   繁体   English

Scapy库修改方法map()

[英]Scapy library modifies the method map()

I use the mapp method to go from list(str) to list(int), but when I call the scapy library. 我使用mapp方法从list(str)转到list(int),但是当我调用scapy库时。 I do not get the same result. 我没有得到相同的结果。

I use python 2.7.13 我使用python 2.7.13

print "E: {}".format(map(int, ['1', '2']))

return 返回

E: [1, 2]

and

from scapy.all import *
print "E: {}".format(map(int, ['1', '2']))

return 返回

E: <itertools.imap object at 0x0405E730

That's the risk you have when you import a module into your namespace in Python. 当您将模块导入Python中的命名空间时,这就是您的风险。

Here, you're using a development version of Scapy and that's a bug (you should not import Scapy's map() , which is the one provided by the six module, when importing Scapy). 在这里,您使用的是Scapy的开发版本,这是一个错误(导入Scapy时,不应导入Scapy的map() ,这是six模块提供的map() )。 You should probably report it . 您可能应该报告它

However, to avoid this, you should import Scapy in its own namespace. 但是,为避免这种情况,您应该在自己的名称空间中导入Scapy。 For example: 例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM