我有一个在C ++程序内部调用的python脚本。python脚本根据当前时间创建目录,将文件放入其中,然后执行返回到C ++。我想将参数文件保存到python程序中创建的目录中。
我认为我的选择是:
我不知道该怎么做。我的python脚本未嵌入。我用
std::string test = "python analyzeData2.py";
system(test.c_str());
调用python脚本。
任何想法如何做到这一点?
我会选择选项B-将目录的位置从python返回到c ++,以便它知道将文件保存在何处。
如果计划使用system(),则如下所示:
char* dirname[64];
FILE* fin;
system("python analyzeData2.py > created.log");
fin = fopen("created.log", "r");
fgets(dirname, sizeof(dirname), fin);
fclose(fin);
/* dirname has contents of created.log */
...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句