python中调用C++可执行文件并传入参数

    技术2025-08-12  6

    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; }

     

    Processed: 0.014, SQL: 10