os.system无法正常工作,但是在命令提示符下输入相同内容 [英] os.system not working, but typing the same thing into the command prompt works

查看:108
本文介绍了os.system无法正常工作,但是在命令提示符下输入相同内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用

os.system('abaqus CAE noGUI=ODBMechens')

它似乎没有运行任何东西,但是如果我自己进入命令提示符并键入在

It doesn't seem to run anything, but if I go to the command prompt myself and type in

abaqus CAE noGUI=ODBMechens

它起作用。我在Windows 10上使用python 2.7。
谢谢

it works. I am using python 2.7 on Windows 10. Thanks

推荐答案

请尝试使用子流程模块(较新):例如

try using the subprocess module (it's newer) instead: for example,

subprocess.call(["ls", "-l"])

在您的示例中为:

subprocess.call('abaqus CAE noGUI=ODBMechens')

更多有关子流程模块与使用os.system调用之间的区别的信息:

More info on the difference between subprocess module and using os.system call:

os.system和子进程调用之间的区别

这篇关于os.system无法正常工作,但是在命令提示符下输入相同内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆