date为列表,存放剪刀石头布
shu=int(input("你选择比赛次数为(比赛次数最好为奇数):")) i=0 shu_com=0 yin_com=0 date = ["剪刀", ["石头"], ["布"]] while i<shu : print('第', i + 1, '局') print("选择你要出的:") print("1.剪刀\n2.石头\n3.布") a = int(input("你出的是:")) - 1 com = int(random.randint(0, 2)) print("电脑出的是:", date[com]) if (a == com): print("这局是平局!") elif (a == 0 and com == 1) or (a == 1 and com == 2) or (a == 2 and com == 0): print("这局是电脑赢!") shu_com = shu_com + 1 else: print("这局是你赢了!") yin_com =yin_com+1 i = i + 1 print('---------') if shu_com==yin_com: print("这次游戏的结果是平局!") elif shu_com<yin_com: print("这次游戏的结果是你赢了!") else: print("这次游戏的结果是你输了!")