import random
all_choices = ['石头', '剪刀', '布']
win_list = [['剪刀', '布'], ['布', '石头'], ['石头', '剪刀']]
prompt = '''请出拳:
(0) 石头
(1) 剪刀
(2) 布
'''
cwin = 0
pwin = 0
while cwin < 2 and pwin < 2:
computer = random.choice(all_choices)
index = int(input(prompt))
player = all_choices[index]
print('你出了:%s,计算机出了:%s' % (player, computer))
if player == computer:
print('\033[32;1m平局\033[0m')
elif [player, computer] in win_list:
print('\033[32;1m你赢了!\033[0m')
pwin += 1
else:
print('\033[31;1m你输了!\033[0m')
cwin += 1
else:
if cwin > pwin:
print('三局两胜!你输了!')
else:
print('三局两胜!你赢了!')