石头剪刀布-5局3胜

n = 1
a = 0
b = 0
p = 0
print('5局3胜模式')
while n <= 5 :
    player = int(input('请玩家输入(0)石头,(1)剪刀,(2)布:'))
    compter = random.randint(0,2)
    lst = ['石头','剪刀','布']
    print('玩家出:',lst[player],'电脑出:',lst[compter])
    if ((player == 0 and compter == 1)
         or (player == 1 and compter == 2)
         or (player == 2 and compter == 0)):
        print('玩家胜')
        a += 1
        if a < 3:
            print('玩家获胜%d盘,还有%d盘获胜'%(a,3-a))
        else:
            print('玩家获胜赢取3盘')
            break
    elif player == compter:
            p += 1
            print('平局继续')
    else:
        print('电脑胜')
        b += 1
        if b < 3:
            print('电脑获胜%d盘,还有%d盘获胜' % (b, 3 - b))
        else:
            print('电脑获胜赢取3盘')
            break
    n += 1
    print('')
    if n == 6:
        a = 0
        b = 0
        n = 1
        print('5盘游戏结束,没分出胜负,重新开始')
;