import randomgamelist = ['石头','剪刀','布'] winlist = [[1,2],[2,3],[3,1]] lostlist = [[1,3],[2,1],[3,2]] resultlist = ["你赢了!","你输了!","打了个平手!"] #翻译牌 def translate(number):tra = ""if number == 1:tra = gamelist[0]elif number == 2:tra = gamelist[1]else:tra = gamelist[2]return tra#电脑出牌 def computershow():randnum = random.randint(1,3)return randnum#计算结果 def calculate(a,b):res = ""if [a,b] in winlist:res = resultlist[0]elif [a,b] in lostlist:res = resultlist[1]else:res = resultlist[2]return resprint("游戏开始!") print("\n")for i in range(1,4):print("第%d次出牌:"%i)user = int(input("请你出牌,输入数字代表东西:1、石头,2、剪刀,3、布:"))computer = computershow()print("你出%s"%translate(user))print("电脑出%s" % translate(computer))result = calculate(user,computer)print("第%d次出牌结果:%s"%(i,result))print("\n")print("游戏结束!")