drjava

python 执行shell命令


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

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

这里用

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

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

   \'%s\' %(shell)会报错

分类:

技术点:

相关文章:

  • 2022-01-02
  • 2021-12-21
  • 2022-12-23
  • 2021-12-21
  • 2021-06-23
  • 2021-12-21
  • 2022-01-02
猜你喜欢
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案