#随机函数import randomcomputer = random.randint(1, 3)print("电脑出:", computer)i = int(input("你要出什么?1代表石头,2代表剪刀,3代表布"))if i == computer: print("平局")elif (computer == 1 and i == 3) or (computer == 2 and i == 1) or (computer == 3 and i == 2): print("你赢了")else: print("你输了")print(computer, "---", i)
运行结果: