Re: os中的execl, execle, exec lp等函数用来执行系统命令,为 什么会replace current process呢?

"Jiahua Huang" <[email protected]> Tue, 22 Jan 2008 12:59:21 +0800
Newsgroups gmane.comp.python.chinese
Message-ID <[email protected]>
exec 就是替换当前进程.

你需要的是 popen  或 system
你的错误在于引号理用了 \ 却没转义,也没保留引号
你需要用
os.system(r"'c:\document and settings\usera\a.exe' -a -b -c")


注意加的 r 和 里边的单引号

Linux 下 os.popen 可以用参数数组,而 Windows 下必须用字符串,
所以你还是得处理空格

2008/1/22 Joey <[email protected]>:
> Hi All,
>
> 想用Python来调用系统命令,遇到了问题。
> 例如想调用a.exe,并跟一些参数,命令格式为: a.exe -a -b -c
> 由于用户当前工作目录不确定,于是决定考虑使用绝对路径
_______________________________________________
python-chinese
Post: send [email protected]
Subscribe: send subscribe to [email protected]
Unsubscribe: send unsubscribe to  [email protected]
Detail Info: http://python.cn/mailman/listinfo/python-chinese