Python 实现简单的石头剪刀布小游戏

直接上代码:

import random

person = int(input('请输入石头[0],剪刀[1],布[2]:'))
computer = random.randint(0,2)

print('机器人输入的是:%d'%(computer))

if person == 0 and computer == 1:
    print('你赢了')
elif person == 1 and computer == 2:
    print('你赢了')
elif person == 2 and computer == 0:
    print('你赢了')
elif person == computer:
    print('平手')
else:
    print('你输了')

你可能感兴趣的:(Python,Python石头剪刀布小游戏)