import random
print('***欢迎开始猜拳游戏***')
while True:
player
= int(input('请出拳:0--剪刀;1--石头;2--布\n'))
if player
== 0:
print('您出了剪刀')
elif player
== 1:
print('您出了石头')
elif player
== 2:
print('您出了布')
while (player
not in [0,1,2]):
print('您输入错误,请重新输入')
player
= int(input('请出拳:0--剪刀;1--石头;2--布\n'))
if player
== 0:
print('您出了剪刀')
elif player
== 1:
print('您出了石头')
elif player
== 2:
print('您出了布')
computer
= random
.randint
(0,2)
if computer
== 0:
print('电脑出了剪刀')
elif computer
== 1:
print('电脑出了石头')
elif computer
== 2:
print('电脑出了布')
if (player
== 0 and computer
== 2) or (player
== 1 and computer
== 0) or (player
== 2 and computer
== 1):
print('玩家胜,哈哈')
elif (player
== computer
):
print('哦,平局,再来一次')
else:
print('电脑胜')
a
= input('要不要退出游戏?:y--退出,n--继续\n')
if a
== "y":
break
print ('GAME OVER')
转载请注明原文地址:https://tech.qufami.com/read-17738.html