simple way:
import os pathname = "Untitled1.exe" os.system(pathname)
with parameter
subprocess.check_call(["Untitled1.exe",'parameter1','parameter2'],stdout = fout)
例如:
import subprocess
result=[]
fout = open('result.txt','w')
for i in range(8,15):
subprocess.check_call(["Untitled1.exe",str(i),'3'],stdout = fout)
print i
fout.close()
fin = open('result.txt','r')
for line in fin:
print line
另外:關於c/c++的main 函數參數傳遞規則見: