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()

 

posted @ 2019-01-24 09:11  effortsing  阅读(1977)  评论(0编辑  收藏  举报