小编ano*_*ous的帖子

subprocess.call()的返回值是多少?

我不确定返回值是什么subprocess.call()意思.

  • 我可以安全地假设零值将始终意味着命令执行成功吗?

  • 返回值是否等同于shell命令的退出状态?

例如,以下几段代码是否适用于Linux上几乎任何命令?

 cmd = "foo.txt > bar.txt"
 ret = subprocess.call(cmd, shell=True)
 if ret != 0:
     if ret < 0:
         print "Killed by signal", -ret
     else:
         print "Command failed with return code", ret
 else:
     print "SUCCESS!!"
Run Code Online (Sandbox Code Playgroud)

请赐教:-)

python linux

37
推荐指数
3
解决办法
6万
查看次数

标签 统计

linux ×1

python ×1