Closed bestkillua closed 3 years ago
PyRun_AnyFile
only returns an error code (0
if successful, a negative number if unsuccessful). It's not possible to return data (like a string) from Python to Go using this function.
To do that you would need to call the function directly using its <python3.PyObject>.CallObject()
method, which would return a PyObject that you could "convert" to a Go string object. (I wrote about a simple example here).
@christian-korneck Thanks a lot
Describe what happened: python file contians only one function return string, but I could't capture its return when use python3.PyRun_AnyFile
Describe what you expected:
Steps to reproduce the issue: