""" 提示:0-石头, 1-剪刀, 2-布 1.出拳 玩家输入出拳 电脑随机出拳 2.判断输赢 玩家获胜 平局 电脑获胜 """ # 导入random模块 import random # 计算电脑出拳的随机数字 computer = random.randint(0, 2) print(computer) player = int(input('请出拳:0-石头, 1-剪刀, 2-布 : ')) # 玩家胜利 P0:C1 或者P1:C2 或者 P2:C0 if (player == 0) and (computer == 1) or (player == 1) and (computer == 2) or (player == 2) and (computer == 0): print('玩家获胜') print(f'你的出拳是{player},电脑出拳是{computer}') elif player == computer: print('此局为平局') print(f'你的出拳是{player},电脑出拳是{computer}') else: print('电脑获胜') print(f'你的出拳是{player},电脑出拳是{computer}')
03-08
9633
