how to run my own external command in python script

This question already has an answer here:

  • Calling an external command in Python 50 answers
  • Run a linux system command as a superuser, using a python script 5 answers

  • 你可以使用subprocess.Popen来达到这个目的:

    import shlex
    import subprocess
    proc = subprocess.Popen(shlex.split('sudo insteon on 23'))
    proc.communicate()
    
    链接地址: http://www.djcxy.com/p/13512.html

    上一篇: 哪个是执行命令的最佳python模块

    下一篇: 如何在python脚本中运行我自己的外部命令