import random
while True:
game = {0:'剪刀', 1: '石头', 2: '布'}
player = input('请输入:剪刀(0) 石头(1) 布(2) 退出(3):')
# isdigit() 判断字符串是否为数字
if player.isdigit():
player = int(player)
# 退出游戏
if player == 3:
print('退出成功,感谢你的使用!')
break
# 判断是否出指定数字
if player not in game:
print('请输入指定数字(0/1/2)!')
continue
else:
print('请输入数字!')
continue
# 随机整数(0,1,2)
computer = random.randint(0,2)
print('player出: %s, computer出: %s' % (game[player], game[computer]))
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('输了,不要走,洗洗手接着来,决战到天亮')