from sys import exit import random def Arrfor(str): #CONTST = CONTST + 1 artificial = input("请输入1-9之间任意一个数字:") art = int(artificial) #将字符串类型转换为int类型 if art < 1: print("数值不合法!还有",CONTST + "次机会哦") Arrfor(str); if art > 9: print("数值不合法!") Arrfor(str) if art == str: print("恭喜你,猜对了!") exit() if art < str: print("小了~") Arrfor(str) if art > str: print("大了") Arrfor(str) print("\n猜数字游戏~ 作者:xyk\n") ran = random.randint(1,9) Arrfor(ran);
时间: 2024-10-19 22:15:12