缺少sys.excepthook,丢失了sys.stderr

时间:2017-04-17 14:02:26

标签: python exception exception-handling stderr ioerror

我有以下代码段。

def do_scheme():
    print """
            <scheme>
            <title>ABC</title>
            <description>ABC is Company</description>
    """
if __name__ == "__main__":
   do_scheme()

当我使用任何其他命令执行此CLI时,例如:“python test.py | echo $ PATH”或“python test.py | cd ..”,它显示以下错误消息:

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

我试过处理sys.excepthook但它没有用。我们可以在这里使用任何装饰器来避免这样的错误信息吗?

0 个答案:

没有答案
相关问题