Python调用多个命令 [英] Python call multiple commands

查看:69
本文介绍了Python调用多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的python脚本调用多个命令。
我尝试使用os.system(),但是,在更改当前目录时遇到了问题。

I would like to invoke multiple commands from my python script. I tried using the os.system(), however, I'm running into issues when the current directory is changed.

示例:

os.system("ls -l")
os.system("<some command>") # This will change the present working directory 
os.system("launchMyApp") # Some application invocation I need to do.

现在,第三个调用启动无效。

Now, the third call to launch doesn't work.

推荐答案

使用&

os.system("ls -l & <some command> & launchMyApp")

这篇关于Python调用多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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