如何抑制导入文件时出现的错误在python中

时间:2015-02-24 23:47:05

标签: 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) 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。

0 个答案:

没有答案