Python不会使用import scapy进行打印 [英] Python doesn't print with import scapy

查看:410
本文介绍了Python不会使用import scapy进行打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入此代码时:

 从scapy.all打印hhhh
导入嗅探
打印bbbb

这是输出:

  C:\Python27 \ python.exe C:/Users/Tamir/PycharmProjects/SIP/main.py 
hhhh
警告:没有路线找到IPv6目的地::(没有默认路由?)

处理完成后退出代码0

为什么第二次打印(bbbb)不起作用?
当我将导入行放入评论或导入另一个库时,它可以正常工作。

解决方案

sys.stdout 被重定向到readline控制台。以这种方式似乎与pycharm不兼容。
请检查:PYTONPATH \Lib\site-packages \scapy \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ://i.stack.imgur.com/Anzuo.pngrel =nofollow noreferrer>



临时解决方案:将stdout重定向到原来的



试试这个:

  import sys 
printhhhh
orig_stdout =来自scapy.all的sys.stdout
导入嗅探
sys.stdout = orig_stdout
打印bbbb


When I enter this code:

print "hhhh"
from scapy.all import sniff
print "bbbb"

this is the output:

C:\Python27\python.exe C:/Users/Tamir/PycharmProjects/SIP/main.py
hhhh
WARNING: No route found for IPv6 destination :: (no default route?)

Process finished with exit code 0

Why doesn't the second print (of "bbbb") work? When I put the import line in a comment, or import another library, it works.

解决方案

sys.stdout is redirected to readline console. It seems not working well with pycharm in this way. Please check: "PYTONPATH\Lib\site-packages\scapy\arch\windows__init__.py"

temporary solution: redirect stdout to the original one

try this:

import sys
print "hhhh"
orig_stdout = sys.stdout
from scapy.all import sniff
sys.stdout =  orig_stdout
print "bbbb"

这篇关于Python不会使用import scapy进行打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆