从monkeyrunner的stdin中读取 [英] Read from stdin with monkeyrunner
问题描述
如何使用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屋!