大佬教程收集整理的这篇文章主要介绍了如何阅读使用Python在命令行中生成的“错误”内容?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
tesTing在Linux 32bit上。 Python 2.7
我想在Python中运行这个命令
nasm -f elf target.s
target.s:422: error: symbol `loc_8049B1C' undefined target.s:423: error: symbol `loc_80499E8' undefined target.s:424: error: symbol `loc_80499AE' undefined
我首先使用这个:
子POSIX线程是如何取消的
参数在epoll_event结构中的意义(epoll)
使用linux脚本命令
在Perl中的“打开function”和“触摸命令”之间的区别?
infos = subprocess.check_output(["nasm","-f","elf","final.s"],stderr=subprocess.STDOUT)
Python告诉我
subprocess.CalledProcessError: Command '['nasm','-f','elf','target.s']' returned non-zero exit status 1
并终止程序
然后我用这个:
infos = os.popen("nasm -f elf target.s").read()
那么信息什么都没有。
所以基本上任何人都可以告诉我如何获得错误消息信息,同时保持Python程序正常运行?
谢谢!
确定可移植的alignment最严格的数据types
usb-skeleton.c不起作用
我怎样才能从Python程序发送信号?
如何find哪些进程已经写入Linux上的文件
如果有的话,我会使用.communicate()来获得标准错误。
s = 'nasm -f elf target.s' proc = subprocess.Popen(s.split(),stdout=subprocess.PIPE,stderr=subprocess.PIPE) (stdout,stderr) = proc.communicate() if stderr: print stderr
当进程具有非零的返回状态时,检查输出引发CalledProcessError。
try: infos = subprocess.check_output(["nasm",stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print e.output
以上是大佬教程为你收集整理的如何阅读使用Python在命令行中生成的“错误”内容?全部内容,希望文章能够帮你解决如何阅读使用Python在命令行中生成的“错误”内容?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。