代码如下:
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
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com