问题描述
当真时:回复 = input('输入文本')如果回复 == '停止':休息打印(回复.上())
结果是:
<块引用>输入文本:Traceback(最后一次调用):<module> 中的文件C:PythonProjects5.py",第 2 行回复 = input('输入文本:')EOFError:读取一行时出现EOF[在0.2s内完成,退出代码为1]
它只在 Sublime Text 2 中.我试过 IDLE,试过命令行,一切都很完美.Subleme 为什么要冲我大喊大叫?
顺便说一句,也许你也可以解释一下在这种情况下 EOF 可能意味着什么.当然,我已经阅读了文档,如果从输入中读取 EOF,则会引发相应的错误.我想模拟这种情况.输入仅与键盘有关吗?如果是,我应该输入什么组合键来获得 EOF?
提前谢谢你.
我也遇到了同样的问题.Sublime Text 默认控制台的问题是它不支持输入.
要解决这个问题,你必须安装一个名为 SublimeREPL 的包.SublimeREPL 提供了一个接受输入的 Python 解释器.
有一篇文章解释了详细解决方案.
SublimeREPL 的 GitHub 页面
while True:
reply = input('Enter text')
if reply == 'stop': break
print(reply.upper())
The result was:
Enter text:Traceback (most recent call last): File "C:PythonProjects5.py", line 2, in <module> reply = input('Enter text:') EOFError: EOF when reading a line [Finished in 0.2s with exit code 1]
It is only in Sublime Text 2. I tried IDLE, tried command line, everything is perfect. Why should Subleme shout at me?
By the way, maybe you could also explain my what EOF may mean in such situation. Of course, I have read in the documentation, that if EOF is read from input, the appropriate error is raised. I would like to model this situation. Is input only about the keyboard? If yes, what combination of keys should I input to get EOF?
Thank you in advance.
I had the same problem. The problem with the Sublime Text's default console is that it does not support input.
To solve it, you have to install a package called SublimeREPL. SublimeREPL provides a Python interpreter which accepts input.
There is an article that explains the solution in detail.
GitHub page for SublimeREPL
这篇关于Python 3:读取一行时的 EOF(Sublime Text 2 很生气)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!