Getting Python script return value

I have an external C # program that runs a Python script using a class Process.

My script returns a numeric code, and I want to get it from my C # program. Is it possible?

The problem is that I get the return code python.exeinstead of the code returned from my script. (For example,. 3)

+3
source share
1 answer

The interpreter does not return a value at the top of the Python stack if you do not:

if __name__ == "__main__":
    sys.exit(main())

or if you call sys.exitin elsewhere.

It contains much more documentation on this issue.

+8
source

Source: https://habr.com/ru/post/1714319/


All Articles