suppress scapy warning message when importing the module

后端 未结 4 1856
無奈伤痛
無奈伤痛 2021-02-19 09:06

I\'m writing a small script, that gathers some information using scapy and then returns some xml code, that I\'ll pass on to the xmlrpc interface of metasploit. I\'d like it tha

4条回答
  •  庸人自扰
    2021-02-19 09:19

    I think this is the correct way.

    >>> import sys
    >>> sys.stderr = None            # suppress stderr
    >>> from scapy.all import *
    >>> sys.stderr = sys.__stderr__  # restore stderr
    >>> print("other errors can be shown", file=sys.stderr)
    other errors can be shown
    >>> 
    

提交回复
热议问题