python代码:
import os
main = r"D:\c++_code\Parser\bin\Debug\Parser.exe" #c++生成的exe文件执行位置
os.system(main +' ' +input_file+' '+out_file) #调用os.sysytem函数,函数以空格隔开这里参数为input_file,out_file
C++代码
int main(int argc,char* argv[]){
for(int x = 0;x< argc;x++){
cout<< "the send parameter"<<x<<"num is:"<<argv[x]<<endl;
}
return 0;
}
本文介绍了一个使用Python调用C++编译后的exe文件的实例,展示了如何通过os.system函数执行外部程序,并传递参数。C++代码接收并打印了从Python传来的参数。
1498

被折叠的 条评论
为什么被折叠?



