我们需要游戏的效果是
代码分析
“test.py”
<strong><span style="font-size:18px;"># coding=utf-8 guess = 1 import random ret = random.randint(1,10) while guess != ret: tmp = input("请输入数字:") guess = int(tmp) if guess == ret: print("猜对了") else: if guess > ret: print("大了大了...") else: print ("小了小了") print("游戏结束了")</span></strong>