Read from stdin with monkeyrunner

核能气质少年 提交于 2021-01-28 05:53:41

问题


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

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

I also tried the following:

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?


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/34956663/read-from-stdin-with-monkeyrunner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!