从monkeyrunner的stdin中读取 [英] Read from stdin with monkeyrunner

查看:57
本文介绍了从monkeyrunner的stdin中读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Monkeyrunner从stdin中读取内容?我尝试了以下代码.

How do I read from stdin with monkeyrunner? I tried the following code.

import sys
print("type something")
something = sys.stdin.readline()
print(something)

我还尝试了以下方法:

print("type something")
something = raw_input()
print(something)

在两种情况下,程序都会打印键入某些内容",但是在我键入某些内容后它没有响应.看来我犯了一些愚蠢的错误?

In both cases the program prints "type something" but it does not respond after I type something. It seems i am making some silly mistake?

推荐答案

这似乎是

This seems to be a bug with Jython 2.5.3, the version that is included with MonkeyRunner. The issue says Mac OS X but I am able to reproduce on Ubuntu.

要解决此问题,您可以从 Jython网站(

To fix it, you can download the Jython 2.5.4rc1 standalone Jar from the Jython website (download link) and copy it into the $SDK/tools/lib directory. Note that the Jython 2.7.0 standalone Jar will not work properly. You don't need to rename the new Jar, but you do need to (re)move the old jython-standalone-2.5.3.jar from the directory.

另一个选择(如果只需要用户输入)是使用输入函数在MonkeyRunner类中.

Another option (if you only need user input) is to use the input function in the MonkeyRunner class.

这篇关于从monkeyrunner的stdin中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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