我正在做一个小家庭项目,因为我正在学习python(初学者),我自己做了一个俄罗斯轮盘游戏,它在最后一行解析时出现了意外的EOF。所以如果有人可以帮我解决什么问题,我将非常感激。
import random
print ("Welcome to Russian Roulette without guns :/ ")
amount = input("How many players? 2 or 3 or 4:")
if amount == ("2"):
print ("Player 1 Name")
player_1 = input(" ")
print ("Player 2 Name")
player_2 = input(" ")
print (player_1)
enter = input("Click Enter:")
if enter == (""):
number = random.randint(1, 2)
print (number)
if number == 1:
print (player_1)
print ("You dead")
print ("---------")
print (player_2)
print ("You win")
else:
print (player_2)
enter_2 = input("Click Enter:")
if enter_2 == (""):
number_2 = random.randint(1, 2)
if number_2 == 1:
print (player_2)
print ("You Lose")
print ("---------")
print (player_1)
print ("You win")
elif amount == ("3"):
print ("Player 1 Name")
player_1 = input(" ")
print ("Player 2 Name")
player_2 = input(" ")
print ("Player 3 Name ")
player_3 = input(" ")
print (player_1)
enter_3 = input("Click Enter:")
if enter_3 == (""):
number_3 = random.randint(1, 1)
print (number)
if number == 3:
print (player_1)
print ("You Dead")
print ("Your Out")
print ("-------------")
print ("{0}, {1} You are still in".format(player_1, player_2)
答案 0 :(得分:1)
在最后一行,您缺少一个右括号。它应该是:
print ("{0}, {1} You are still in".format(player_1, player_2))
答案 1 :(得分:0)
EOF是文件的结尾所以它通常是一个意外的程序终止,这很可能是由python中的一些东西引起的:如果你错过了括号,或者遗漏了;在之前的最后一行/行中(因此它作为一行运行而不是;)。但是我可以告诉你,你错过了最后一个print语句末尾的括号。这也只是我建议的一个小改进,评论您的代码python非常容易阅读,但它对于那些不易阅读的语言很好。