python subprocess 模块
生活随笔
收集整理的這篇文章主要介紹了
python subprocess 模块
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
subprocess 模塊中有一個功能Popen , 可以在代碼中調用系統的命令
其功能比os.system 更加強大
代碼示例:
command = 'python -u %s/generalMaker.py %s %s' % (module_dir, ' '.join(sys.argv[1:]), flagsToAppend) args = shlex.split(command) generalMaker = Popen(args) generalMaker.wait()上述代碼中,首先用shlex.split 函數分割命令行參數,然后將參數傳遞給Popen 函數,執行對應的系統命令,wait() 函數表示等待系統命令執行結束
?
總結
以上是生活随笔為你收集整理的python subprocess 模块的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HDU2521 反素数【因子数量+打表】
- 下一篇: web02--jsp数据传递