python批量执行shell命令

[root@master ~]# cat a.py
#!/usr/bin/python
# -*- coding:UTF-8 -*-

import subprocess

def fun():
    subprocess.call(["touch /rubbish/test1"], shell=True)
    subprocess.call(["touch /rubbish/test2"], shell=True)
    print("创建文件3")
    subprocess.call(["touch /rubbish/test3"], shell=True)
    subprocess.call(["touch /rubbish/test4"], shell=True)
    subprocess.call(["touch /rubbish/test5"], shell=True)
    print("创建文件6")
    subprocess.call(["touch /rubbish/test6"], shell=True)

fun()
原文地址:https://www.cnblogs.com/effortsing/p/10312629.html