赞
踩
# 使用import导入随机工具包random
# 注意在导入工具包的时候应将导入的语句放在代码的顶部
# 这样可以使代码在有需要的时候可以随时调用工具包中的工具
player = int(input("请输入您的选择_石头-1、剪刀-2、布-3:"))
computer = random.randint(1, 3)
print("玩家出的是 %d, 电脑出的是 %d" % (player, computer))
if player == computer:
print("平局!")
elif ((player == 1 and computer == 3)
or (player == 2 and computer == 1)
or (player == 3 and computer == 2)):
print("computer win! ")
else:
print("player win! ")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。