任何這裏之前是的東西的清單,我在努力,試圖瞭解這一情況看:我得到一個EOFError,因爲我的Python程序中有輸入()。我甚至不知道我爲什麼擁有它。我應該如何解決它?
how to check for eof in python
what is eof and what is its significance in python
whats-wrong-question-relied-on-files-exceptions-error-eoferror
How-does-one-fix-a-python-EOF-error-when-using-raw_input
這裏是我的代碼:
#!/usr.bin/env python
# Errors
error1 = 'Try again'
# Functions
def menu():
print("What would you like to do?")
print("Run")
print("Settings")
print("Quit")
# The line below is where I get the error
menu_option = input("> ")
if 'r' in menu_option:
run()
elif 's' in menu_option:
settings()
elif 'q' in menu_options():
quit()
else:
print(error1)
menu()
這裏是我的錯誤(幫助我與其他兩個錯誤將是非常好的你):
Traceback (innermost last):
File "C:\Program Files\Python\Tools\idle\ScriptBinding.py", line 131, in run_module_event
execfile(filename, mod.__dict__)
File "C:\Documents and Settings\MyUser\Desktop\MyProgram.py", line 73, in ?
menu()
File "C:\Documents and Settings\MyUser\Desktop\MyProgram.py", line 24, in menu
menu_option = input("> ")
EOFError: EOF while reading a line
我試圖改變代碼,但沒有發生。
你使用python2.x或python3.x? – mgilson
你最近在做什麼?你爲什麼要發送EOF? – geoffspear
你的程序應該交互式地等待輸入;你輸入了什麼?以空字符串作爲輸入,這可能會導致此錯誤。此外,您可能想使用'raw_input()'而不是'input()',因爲(在Python2中)第一個函數也會計算您輸入的表達式。 – Alfe