标签:computer == input format code import print orm 石头剪刀布
1 import random 2 try: 3 while True: 4 player = int(input(‘请输入:1(石头) 2(剪刀) 3(布):‘)) 5 computer = random.randint(1,3) 6 print(‘玩家输入的是{},电脑输入的是{}‘.format(player,computer)) 7 if player in (1,2,3): 8 if ((player==1 and computer==2) 9 or (player==2 and computer==3) 10 or (player==3 and computer==2)): 11 print(‘玩家赢了‘) 12 elif player==computer: 13 print(‘玩家和电脑平手‘) 14 else: 15 print(‘电脑赢了‘) 16 print(‘*‘*50) 17 else: 18 print(请输入正确的数值) 19 continue 20 except: 21 print(‘游戏结束,请再次启动并重新输入正确的数值(1,2,3)!‘)
标签:computer == input format code import print orm 石头剪刀布
原文地址:https://www.cnblogs.com/nuochengze/p/12617133.html