检索Python脚本的返回值 [英] Retrieving the return value of a Python script

查看:252
本文介绍了检索Python脚本的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用过程类。

我的脚本返回执行一个Python脚本外部C#程序一个数字代码,我想从我的C#程序检索它。这可能吗?

My script returns a numerical code and I want to retrieve it from my C# program. Is this possible?

现在的问题是,我得到的返回码 python.exe 而不是代码从我的脚本返回。 (例如, 3

The problem is, I'm getting the return code of python.exe instead of the code returned from my script. (For example, 3.)

推荐答案

该解释不返回

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

如果您对通话sys.exit 在别处。

在这里,在这个问题上有更多的文档。

这篇关于检索Python脚本的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆