import random #引入随机模块
while True:
choice=["石头","剪刀","布"]
users_choice=input("请输入你的选择(石头,剪刀,布):")
computer_choice=random.choice(choice)
print("------对战过程------")
print("你的选择是:", users_choice)
print("电脑的选择是:", computer_choice)
if users_choice=="退出":
break
elif users_choice not in choice:
print("你的输入有误,请重新输入\n")
elif users_choice=="石头"and computer_choice=="剪刀" or users_choice=="布" and computer_choice=="石头" or users_choice=="剪刀" and computer_choice=="布":
print("恭喜你赢了!\n")
elif users_choice==computer_choice:
print("平局!\n")
else:
print("抱歉,你输了!\n")
python写石头剪刀布的小游戏
最新推荐文章于 2024-11-05 15:28:12 发布