没有合适的资源?快使用搜索试试~ 我知道了~
首页在python 中实现运行多条shell命令
资源详情
资源评论
资源推荐

在在python 中实现运行多条中实现运行多条shell命令命令
今天小编就为大家分享一篇在python 中实现运行多条shell命令,具有很好的参考价值,希望对大家有所帮助。
一起跟随小编过来看看吧
使用py时可能需要连续运行多条shell 命令
1.
# coding: UTF-8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import subprocess
import os
import commands
#os.system('cmd1 && cmd2')
cmd1 = "cd ../"
cmd2 = "ls"
cmd = cmd1 + " && " + cmd2
#如下两种都可以运行
subprocess.Popen(cmd, shell=True)
subprocess.call(cmd,shell=True)
2.也可以将多条也可以将多条shell写入写入.sh 文件文件.然后运行然后运行.sh文件文件
以上这篇在python 中实现运行多条shell命令就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支
持我们。

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0