I'm working with c++. I need to execute a python script with condition
int main()
{
if(op==1)
{
RUN("MUL.py"); // execute MUL.py script
}
else
{
RUN("DIV.py"); // execute DIV.py script
}
return 0;
}
I can do like below:
Py_Initialize();
PyRun_SimpleString(code);
Py_Finalize();
Here, I have to make a string. Then I need to run.
But, I don't want to do this. I already have a .py file. All I need to run that file.
something like: py_run(MUL.py)
My python code will do some large calculation for me. That will write the answer in a file. I will read that answer from that file in my c++ code.
How can I do this?