点击查看【bilibili】

    学习代码如下:

    1. """
    2. 1、出拳
    3. 玩家:手动出拳
    4. 电脑:1.固定出拳 2.随机出拳
    5. 2、判断输赢
    6. 玩家获胜
    7. 电脑获胜
    8. 平局
    9. """
    10. import random
    11. #玩家获胜
    12. player = int(input('请出拳:0--石头;1--剪刀;2--布'))
    13. computer = random.randint(0,2)
    14. print(computer)
    15. if ((player == 0) and (computer == 1)) or ((player == 1) and (computer == 2)) or ((player == 2) and (computer == 0)):
    16. print('恭喜玩家获胜')
    17. elif player == computer:
    18. print('打平了哟')
    19. else:
    20. print('恭喜电脑获胜')

    提醒:调用模块时,需要放前面