天天看點

Python調用系統指令的兩種方式

1、os.system()函數,傳回指令退出狀态。

Python調用系統指令的兩種方式
2、os.popen()函數,傳回一個檔案對象。
Python調用系統指令的兩種方式
擴充(擷取非系統指令的輸出)

#encoding=utf-8
from subprocess import check_output
cmd = 'my.exe 參數...'
print check_output(cmd)