while True: computer = random.randint(0,2) people = int(input("请做出选择(0:石头 1:剪刀 2:布):")) if computer == people == 0: print("电脑:石头 玩家:石头 结果:平局") elif computer == people == 1: print("电脑:剪刀 玩家:剪刀 结果:平局") elif computer == people == 2: print("电脑:布 玩家:布 结果:平局") elif computer == 0 and people == 1: print("电脑:石头 玩家:剪刀 结果:你输了") computer_win_count += 1 elif computer == 0 and people == 2: print("电脑:石头 玩家:布 结果:你赢了") people_win_count += 1 elif computer == 1 and people == 0: print("电脑:剪刀 玩家:石头 结果:你赢了") people_win_count += 1 elif computer == 1 and people == 2: print("电脑:剪刀 玩家:布 结果:你输了") computer_win_count += 1 elif computer == 2 and people == 0: print("电脑:布 玩家:石头 结果:你输了") computer_win_count += 1 elif computer == 2 and people == 1: print("电脑:布 玩家:剪刀 结果:你赢了") people_win_count += 1
if computer_win_count == 2 and people_win_count < 2: print("最终结果:电脑获胜") break if computer_win_count < 2 and people_win_count == 2: print("最终结果:你获胜") break