开发者

python + win32: simple way to run a process and print its error code?

I'm running Windows XP and want to run a process and print its exit code. I don't have a C compiler, nor do I want to use one. I do have Python though, so I figu开发者_StackOverflow社区re it's probably the easiest way to do this.

How can I write a quick python script to run a process and print its exit code?


never mind, found it in the subprocess module:

 import subprocess;
 retcode = subprocess.call(["ls","-l"])


Subprocess has all your answers

>>> import subprocess
>>> command = ['foo.exe', 'arg1', 'arg2']
>>> process = subprocess.Popen(command, shell=True)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜