时间:2021-07-01 10:21:17 帮助过:92人阅读
import random
guess_list = ["石头","剪刀","布"]
guize = [["布","石头"],["石头","剪刀"],["剪刀","布"]]
while True:
computer = random.choice(guess_list)
people = input('请输入:石头,剪刀,布\n').strip()
if people not in guess_list:
people = input('重新请输入:石头,剪刀,布\n').strip()
continue
if computer == people:
print("平手,再玩一次!")
elif [computer,people] in guize :
print("电脑获胜!")
else:
print("人获胜!")
break