Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何抑制在python中导入文件时出现的错误_Python_Import_Stderr_Suppress Warnings - Fatal编程技术网

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

如何抑制在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

我有一个程序,它导入一个文件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