如何从python脚本中获取字符串值? [英] How can I get a string value returned from a python script?

查看:131
本文介绍了如何从python脚本中获取字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直致力于创建一个同时使用java和python的小应用程序。 GUI使用java,我想使用一个按钮来调用python脚本,该脚本将字符串返回给java应用程序。问题是我不知道如果在sys.exit()中返回字符串打印到错误流时如何从python返回字符串。

解决方案

使用流程类 [ ^ ],它允许您捕获外部进程的输出流

I've been working on making a small application which uses both java and python. The GUI uses java and I would like to use a button to call a python script which will return a string to the java application. Problem is I have no idea how to return a string from python as strings are printed to to the error stream if returned in sys.exit().

解决方案

Use the Process class[^] which allows you to capture the output stream of the external process.


这篇关于如何从python脚本中获取字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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