我的问题是输入命令有问题。它不允许我完全浏览菜单,因为每次退出菜单时(例如,如果我按Enter时),此消息都会显示“ SyntaxError:解析python时出现意外的EOF”,它表示我的第一个菜单中的第一个输入命令
我已经尝试对输入命令的用法使用不同的语法。我什至试图重新排列我应该放置输入命令的位置。我尝试使用raw_input代替输入。但是,当我每次根据菜单方法选择应该工作的号码时,都不会通过。出现我的除外错误。第一菜单和第一子菜单代码在下面。
def main():
player_list = read_data()
#menu method
print("*** Welcome to tennis game ***")
print("1. New Game\n2. Show Table\n3. Exit")
while True:
try:
x = int(input("Enter a choice : "))
if x == 1:
new_game()
break
elif x == 2:
show_table(name, chance, wins, played)
print("Here is the current table")
break
elif x == 3:
write_data(player_list)
print("Thanks for playing!")
exit()
else:
print("Number must be between 1 and 3!")
except NameError:
print("Input was not a number! Please try again")
except ValueError:
print("Input was incorrect! Pleas try again")
Traceback (most recent call last):
File "main.py", line 179, in <module>
main()
File "main.py", line 54, in main
x = int(input("Enter a choice : "))
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing