dairui130

导航

python 执行shell命令


# -*- coding: utf-8 -*-

def exec_shell(shell):
    exec_ = '''"%s"''' % (shell)
    print exec_
    os.system(exec_)

这里用

'''"%s"''' % (shell)

的原因是,假如传入的是多行的shell命令,使用

   '%s' %(shell)会报错

posted on 2019-05-08 10:48  dairui130  阅读(303)  评论(0编辑  收藏  举报