Why input() gives an error when I just press enter?

后端 未结 4 1896
囚心锁ツ
囚心锁ツ 2020-11-29 12:31

I have the following python code:

print \'This is a simple game.\'
input(\'Press enter to continue . . .\')
print \'Choose an option:\'

...
<
4条回答
  •  误落风尘
    2020-11-29 13:10

    In Python 2.x, input() is equivalent to eval(raw_input()). And eval gives a syntax error when you pass it an empty string.

    You want to use raw_input() instead.

提交回复
热议问题