从monkeyrunner的stdin中读取

从monkeyrunner的stdin中读取

本文介绍了从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?

推荐答案

这似乎是 Jython 2.5.3(MonkeyRunner附带的版本)中的错误.该问题显示为Mac OS X,但我可以在Ubuntu上进行复制.

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网站(下载链接)并将其复制到 $ SDK/tools/lib 目录中.请注意,Jython 2.7.0独立Jar将无法正常工作.您无需重命名新的Jar,但是您确实需要从目录中(重新)移动旧的 jython-standalone-2.5.3.jar .

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中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:02