call external .exe in python
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 函数参数传递规则见:
c语言main函数参数说明 http://www.cnblogs.com/viviwind/archive/2012/09/05/2671905.html
注意:argc不用传,argv[0]是文件名,从argv[1]开始才是参数。版权声明:本文为博主原创文章,未经博主允许不得转载。