Reading stdin in Spyder

十年热恋 提交于 2019-12-10 18:40:01

问题


I have some programming assignments which read input data from stdin like this:

text = sys.stdin.readline().strip()

I am using Spyder as my development environment, and am not able to find a way to give the stdin. So, I added a -infile option to the code, and am reading from the file.

However, when submitting, I need to revert back to reading the stdin. How can I read stdin in the first place? I know how to do this from linux command line, but for now have to use windows.


回答1:


(Spyder maintainer here) The code you posted only works to read text when you run it in a system terminal (i.e. bash or cmd.exe).

It doesn't work in Spyder because its terminals are implemented in a different technology (PyQt vs. readline).



来源:https://stackoverflow.com/questions/46671039/reading-stdin-in-spyder

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