如何抑制在python中导入文件时出现的错误
我有一个程序,它导入一个文件X,看起来像这样如何抑制在python中导入文件时出现的错误,python,import,stderr,suppress-warnings,Python,Import,Stderr,Suppress Warnings,我有一个程序,它导入一个文件X,看起来像这样 ... ... importing rest of the stuff ... print "Debug A" from CA import & print "Debug A" ... 这使程序的输出为 Debug A 2015-02-24 15:40:03.374 Python[1778:108266] PyObjCPointer created: at 0x10e565160 of type @ Debug B 我试过使用 a) wa
...
...
importing rest of the stuff
...
print "Debug A"
from CA import &
print "Debug A"
...
这使程序的输出为
Debug A
2015-02-24 15:40:03.374 Python[1778:108266] PyObjCPointer created: at 0x10e565160 of type @
Debug B
我试过使用
a) warnings.filterwarnings("ignore")
b)
err(or stdout, tried this too) = sys.stderr
from CA import &
sys.stderr = err
但我就是无法摆脱这个信息。有什么建议吗?
同样,当我通过python abc>somefile运行这个文件时
它仍然会出现,但python abc 2>somefile会将其带走,因此看起来像是一个stderr