简体   繁体   English

使用raw_input时出现EOFError

[英]EOFError when using raw_input

I am learning python via codeacademy's python syntax tutorial but when I run the same working code in SublimeText2 the code does not build properly. 我正在通过codeacademy的python语法教程学习python,但是当我在SublimeText2中运行相同的工作代码时,代码无法正确构建。 I have version 2.7 of Python installed on my mac for the record. 我已在Mac上安装了Python的2.7版,以备记录。

original = raw_input('Enter a word:')
print original

I am wondering why this code would work in codeacademy's syntax lesson but not work in my text editor. 我想知道为什么此代码在codeacademy的语法课中可以工作,而在我的文本编辑器中却不能工作。 The error produced occurs immediately upon running the code. 运行代码后立即产生错误。 The user is given no chance to respond to the prompt. 用户没有机会响应提示。

Traceback (most recent call last):
File "/Users/Tom/Documents/firstsublimeentry.py", line 1, in <module>
original = raw_input('Enter a word:')
EOFError: EOF when reading a line
Enter a word:[Finished in 0.0s with exit code 1]

Sublime Text's console is not able to capture input. Sublime Text的控制台无法捕获输入。 To execute your code, either use a python shell, execute it from the command line, or install the Sublime Package SublimeREPL via Package Control. 要执行代码,请使用python shell,从命令行执行它,或通过Package Control安装Sublime Package SublimeREPL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM