In my C++ code, I am executing some commands using python as follows:
std::string word = "Something";
std::cout << word; //will execute using C++
PyRun_SimpleString("import sys"); // will execute using Python
The problem is how to pass word
to Python ?
I want something like this: PyRun_SimpleString("Hello %" %word);
In Python you can do: "Hello {}".format(word)
and the result "Hello Something"
I found something like this: sprintf(str, "hello %s", word);
But the problem is printf
or sprintf
will send it to console and will not return the value of word.
Aucun commentaire:
Enregistrer un commentaire