当前位置:首页>python>Python基础实战:从零写一个猜数字游戏

Python基础实战:从零写一个猜数字游戏

  • 2026-08-18 23:10:37
Python基础实战:从零写一个猜数字游戏
从零写一个猜数字游戏:Python基础语法全串讲
学Python最好的方式,就是一边学语法一边写项目。今天我们从零开始,做一个「猜数字小游戏」。这个游戏看起来简单——电脑随机想一个数,你来猜,它告诉你"大了"还是"小了"——但要把体验做好,几乎要用到Python基础阶段的所有核心语法。我们边讲边写,从一个空文件开始,一步步把它搭出来。
一、Hello World 与输入输出
任何编程语言的学习都从"让计算机说句话"开始。Python做这件事只需要一行:
print("Hello, World!")
print()是Python的内置输出函数,作用是把括号里的内容显示到屏幕上。它可以输出字符串(用引号包裹的文本),也可以输出数字、变量,甚至一次输出多个值:
print("欢迎来到猜数字游戏")     # 输出字符串print(42)                   # 输出数字print("答案"42True)      # 一次输出多个值,默认空格分隔
有输出就有输入。input()函数让程序等待用户从键盘输入数据:
name = input("你叫什么名字?")print("你好,", name)
这里有一个非常重要的细节:input()返回的永远是字符串,哪怕用户输入的是数字 "123",Python拿到的也是字符串 "123" 而不是整数 123。如果要做数学运算,必须手动转换类型。这一点后面会反复提到。print()还有几个实用参数:sep控制多个值之间的分隔符,end控制输出末尾加什么字符(默认是换行符\n)。
print("A""B""C", sep="-")        # 输出:A-B-Cprint("加载中", end="...")            # 输出不换行:加载中...
好,有了输入输出,我们的游戏就可以和玩家"对话"了。
二、变量与数类型
变量就是给数据取个名字,方便后面反复使用。Python的变量不需要声明类型,赋值即创建:
answer = 42           # 整数player_name = "小赵"   # 字符串is_playing = True     # 布尔值score = 3.5           # 浮点数
Python是动态类型语言——同一个变量可以随时改变类型,x = 10之后再来一句x = "hello"完全合法。这在C或Java里是不允许的。Python根据赋的值自动确定类型,不需要程序员操心。
Python的四种基础数值类型:
int(整型):整数,没有大小限制。42-1000都是整型。Python的整数可以无限大,不会溢出。
float(浮点型):小数,3.140.1-2.5。有一个经典陷阱:0.1 + 0.2的结果是0.30000000000000004而不是0.3,因为计算机用二进制存储小数,存在精度损失。比较两个浮点数是否相等,推荐用 math.isclose() 而不是==
bool(布尔型)只有TrueFalse两个值,首字母必须大写。布尔型本质上是整数的子类——True等价于1False等价于0。所以True + True等于2True * 5等于5
str(字符串):用引号包裹的文本,单引号'hello'和双引号"hello"都可以,三引号'''...'''可以写多行文本。字符串是不可变的——一旦创建就不能修改某个位置的字符,s[0] = 'H'会报错。
类型转换,不同类型之间可以手动转换:
num = int("42")        # 字符串 → 整数:42text = str(100)        # 整数 → 字符串:"100"decimal = float("3.14")  # 字符串 → 浮点数:3.14flag = bool(0)         # 整数 → 布尔值:False
有个简便判断方法:在Python中,0、空字符串""、空列表[]None这些"空"的值,转为布尔值都是False;其他非空值都是True
变量命名规范:
Python社区遵循PEP8编码规范。变量名用小写字母加下划线(如play_name),常量用全大写(如MAXATTEMPTS),类名用驼峰(如GamePlayer)。名字要有意义,a = 42不如answer = 42清楚。另外,变量名不能以数字开头,不能使用Python的35个关键字(如 ifforclass)作为变量名。
三、动手写:游戏第一版
讲完变量和输入输出,我们就可以写出游戏的第一个能跑的版本了:
import randomanswer = random.randint(1100)     # 随机生成1-100之间的整数guess = int(input("猜一个1-100的数字:"))if guess == answer:    print("恭喜你,猜对了!")else:    print(f"猜错了,答案是{answer}")
先别看这只有几行,已经包含了:模块导入(import random)、变量赋值、函数调用、类型转换(int())、条件判断(if...else)和f-string格式化输出。
random.randint(1, 100) 是random模块提供的函数,返回一个1到100之间的随机整数(包含1和100)。random是Python的标准库,不需要额外安装,直接导入即可。
四、运算符:程序里的"计算引擎"
游戏第一版只能猜一次,体验太差。要让它更好玩,我们需要计分、比较、判断范围——这些都离不开运算符
算术运算符
+ 加、- 减、* 乘、/ 除(永远返回浮点数)、// 整除(向下取整)、% 取余、** 幂运算。
几个容易踩的坑:/ 永远返回浮点数(6 / 3 结果是 2.0);// 是向下取整不是截断(-3 // 5 结果是 -1);Python不支持C语言的 ++ 和 --,自增写 i += 1。运算符还有个有趣的用法:"ha" * 3 得到 "hahaha"[1, 2] * 2 得到 [1, 2, 1, 2],用来快速重复序列。
比较运算符
==(等于)、!=(不等于)、><>=<=,返回布尔值。
Python有一个非常舒服的语法糖——链式比较
# 判断数字是否在1-100之间if 1 <= guess <= 100:    print("输入有效")# 等价于 C/Java 中的写法if guess >= 1 and guess <= 100:    print("输入有效")
链式比较读起来就像数学公式,比两个条件加and简洁得多
逻辑运算符
and(与)、or(或)、not(非),用来组合多个条件。
Python的逻辑运算符有一个重要特性:惰性求值(也叫短路)。3 > 5 and a > 3 中,因为 3 > 5 已经是False,Python直接返回False,根本不去计算a > 3,即使a没定义也不会报错。or同理,遇到第一个True就停下来。利用这个特性可以写出简洁的代码:
# 如果列表非空,取第一个元素result = my_list and my_list[0]
f-string:最好用的格式化方式
Python 3.6+推荐使用f-string,在字符串前f,花括号{}里直接写变量或表达式:
name = "小赵"attempts = 7print(f"{name}用了{attempts}次猜中,平均每次耗时{attempts * 0.5:.1f}秒")
:.1f是格式说明符,表示保留1位小数。f-string比传统的%格式化和.format() 方法都更直观,执行效率也更高。
五、选择结构:让程序学会"判断"
现在来给游戏加上"大了/小了"的提示。这需要用到条件判断,也就是 if...elif...else 结构。
if guess == answer:    print("猜对了!")elif guess > answer:    print("太大了,往小猜")else:    print("太小了,往大猜")
Python的选择结构有三种形式:
单分支 if:只判断一个条件,为真就执行,为假就跳过。
双分支 if...else:二选一,非此即彼。Python还支持三元写法 x = "大" if guess > answer else "小",一行搞定简单的二选一。
多分支 if...elif...else:从上往下逐个检查条件,遇到第一个为真的就执行对应代码块,跳过后面所有分支。所以条件的排列顺序很重要——一般从最严格到最宽松。给游戏加上难度选择就是一个典型的多分支场景:
print("选择难度:1-简单(1-50)  2-普通(1-100)  3-困难(1-500)")level = input("请输入选项:")if level == "1":    max_num = 50    max_attempts = 10elif level == "2":    max_num = 100    max_attempts = 7elif level == "3":    max_num = 500    max_attempts = 12else:    print("无效选项,使用默认难度")    max_num = 100    max_attempts = 7answer = random.randint(1, max_num)
六、循环结构:让游戏能反复猜
目前游戏只能猜一次,猜错就结束了。我们需要一个循环,让玩家反复猜,直到猜中为止。
while循环:猜不中就继续
while 循环在条件为真时反复执行代码块,适合"不知道要循环多少次"的场景:
attempts = 0while True:    guess = int(input(f"猜一个1-{max_num}的数字:"))    attempts += 1    if guess == answer:        print(f"恭喜,你用了{attempts}次猜中了答案{answer}!")        break    elif guess > answer:        print("太大了")    else:        print("太小了")    if attempts >= max_attempts:        print(f"次数用完了!答案是{answer}")        break
while True创建一个无限循环,配合break在满足条件时主动跳出。break跳出整个循环,continue则是跳过本轮剩余代码、直接进入下一轮循环
for循环:已知次数的遍历
for循环用于遍历序列或可迭代对象,搭配range()可以精确控制循环次数:
# range(start, stop, step)for i in range(16):       # 12345    print(i)for i in range(0102):   # 02468(步长为2    print(i)
for循环有个Python独有的特性——else子句。当循环正常结束(没被 break 中断)时,会执行else块:
for char in password:    if char == "@":        print("包含特殊字符")        breakelse:    print("没有特殊字符")   # 循环没被break,说明确实没有
这个模式在"搜索"和"验证"场景中特别好用,省去了额外的标志变量。
游戏里加上历史记录
for环可以很方便地展示猜数字的历史:
history = []   # 用一个列表记录每次猜的数# 每次猜完后history.append(guess)# 游戏结束时展示历史print("你的猜测记录:")for i, g in enumerate(history, 1):    hint = "大了" if g > answer else "小了" if g < answer else "对了"    print(f"  第{i}次:{g}{hint})")
enumerate()是Python内置函数,同时返回索引和值,省去了手动维护计数变量。
七、字符串:最常用也最容易被忽视的类型
游戏里大量用到字符串——玩家输入、提示信息、格式化输出。Python的字符串方法非常丰富,这里把最实用的讲一遍。
字符串是不可变的
字符串一旦创建就不能修改其中的字符。name[0] = 'H' 会报错。如果你想"修改"一个字符串,实际上是创建了一个新字符串:
name = "hello"name = "Hello"    # 合法:变量重新指向了新字符串# name[0] = "H"   # 非法:TypeError
常用的分类测试方法
Python提供了一组is开头的方法来判断字符类型:
'5'.isdigit()      # True,纯数字'A'.isupper()      # True,大写'abc'.isalpha()    # True,纯字母'abc123'.isalnum() # True,字母或数字' '.isspace()      # True,空白字符
在游戏里可以用来验证用户输入是否合法:
user_input = input("输入数字:").strip()if user_input.isdigit():    guess = int(user_input)else:    print("请输入一个有效的数字!")
strip、split、join三件套
strip()去掉两端空白字符,split()按分隔符拆成列表,join()把列表拼回字符串:
"  hello  ".strip()              # 'hello'"a,b,c".split(",")              # ['a''b''c']" ".join(["I", "love", "Python"])  # 'I love Python'
拼接字符串时优先用join()而不是+,效率更高。
查找、替换、切片:
msg = "Congratulations"msg.find("rat")        # 3,首次出现的位置(找不到返回-1msg.replace("o""0")  # 'C0ngratulati0ns'msg[0:5]               # 'Congr'(切片:从05,不含5msg[::-1]              # 'snoitalutargnoC'(反转字符串)
切片语法s[start:end:step]非常强大:s[2:8]取下标2到7,s[::2] 每隔一位取一个,s[::-1] 反转整个字符串。
八、异常处理:别让程序随便崩溃
现在的游戏有个致命问题——如果用户输入的不是数字而是字母,int()会直接抛出ValueError,程序当场崩溃。Python用try...except处理这种"预期内的错误":
while True:    user_input = input(f"猜一个1-{max_num}的数字(输入q退出):").strip()    if user_input.lower() == 'q':        print("主动退出,答案是", answer)        break    try:        guess = int(user_input)    except ValueError:        print("输入的不是数字,请重新输入")        continue    if not (1 <= guess <= max_num):        print(f"请输入1-{max_num}范围内的数字")        continue    # ... 猜数字的判断逻辑 ...
异常处理的思路很简单:把"可能出错的代码"放进try块,用except捕获特定类型的异常。ValueError是"值不对"的错误,ZeroDivisionError是"除以零"的错误,TypeError是"类型不对"的错误。每种异常有对应的处理方式。
还有两个实用的搭配:
  • else:没有异常时执行(比如输入正确后执行游戏逻辑)
  • finally无论有没有异常都执行(常用于关闭文件、释放资源)
try:    guess = int(user_input)except ValueError:    print("请输入数字")else:    # 没有异常,正常处理猜测逻辑    attempts += 1    history.append(guess)finally:    # 无论对错都执行    print(f"已猜{attempts}次")
九、完整代码
把上面所有知识点拼在一起,就是一个功能完整的猜数字游戏:
"""猜数字游戏 v1.0——Python基础语法全串讲"""import randomdef play_game():    """一局猜数字游戏"""    # 难度选择    print("\n" + "=" * 30)    print("  欢迎来到猜数字游戏")    print("=" * 30)    print("选择难度:")    print("  1. 简单(1-50,10次机会)")    print("  2. 普通(1-100,7次机会)")    print("  3. 困难(1-500,12次机会)")    level = input("请输入选项(1/2/3):").strip()    if level == "1":        max_num, max_attempts = 5010    elif level == "3":        max_num, max_attempts = 50012    else:        max_num, max_attempts = 1007    answer = random.randint(1, max_num)    attempts = 0    history = []    print(f"\n我想了一个 1-{max_num} 之间的数字,你有{max_attempts}次机会。\n")    while attempts < max_attempts:        user_input = input(f"第{attempts + 1}次猜(输入q退出):").strip()        if user_input.lower() == 'q':            print(f"主动退出。答案是 {answer}")            return attempts, False        # 异常处理:防止非数字输入        try:            guess = int(user_input)        except ValueError:            print("  请输入有效的数字!\n")            continue        # 范围检查        if not (1 <= guess <= max_num):            print(f"  请输入 1-{max_num} 范围内的数字\n")            continue        attempts += 1        history.append(guess)        if guess == answer:            print(f"\n  猜对了!答案就是 {answer}")            print(f"  你用了 {attempts} 次!\n")            break        elif guess > answer:            remaining = max_attempts - attempts            print(f"  太大了!还剩 {remaining} 次机会\n")        else:            remaining = max_attempts - attempts            print(f"  太小了!还剩 {remaining} 次机会\n")    else:        # while正常结束(没被break)= 次数用完了        print(f"\n  次数用完!答案是 {answer}\n")    # 展示历史记录    if history:        print("--- 猜测记录 ---")        for i, g in enumerate(history, 1):            diff = g - answer            if diff == 0:                tag = "正确"            elif diff > 0:                tag = f"大了{diff}"            else:                tag = f"小了{-diff}"            print(f"  第{i}次:{g:>4}  ({tag})")    return attempts, guess == answer if history else Falsedef main():    total_games = 0    total_wins = 0    total_attempts = 0    while True:        attempts, won = play_game()        total_games += 1        total_attempts += attempts        if won:            total_wins += 1        again = input("\n再来一局?(y/n):").strip().lower()        if again != 'y':            break    # 统计面板    print("\n" + "=" * 30)    print("  本次游戏统计")    print("=" * 30)    print(f"  总局数:{total_games}")    print(f"  胜局数:{total_wins}")    win_rate = total_wins / total_games * 100 if total_games > 0 else 0    print(f"  胜率:{win_rate:.1f}%")    avg = total_attempts / total_games if total_games > 0 else 0    print(f"  平均每局猜测次数:{avg:.1f}")    print("  感谢游玩,再见!")if __name__ == "__main__":    main()
十、这个项目用到了哪些基础知识?
回头看看这个100行不到的游戏,已经把Python基础阶段的核心语法几乎全部用上了。
变量与类型answerattemptshistory等变量分别承载了整型、布尔型、列表等不同类型的数据,Python的动态类型让赋值非常自由。
运算符:算术运算attempts += 1g - answer)、比较运算(guess == answer)、链式比较(1 <= guess <= max_num)、逻辑运算(if won)。
字符串strip() 清洗输入、lower()统一大小写、isdigit()验证数字、f-string格式化输出(f"第{i}次:{g:>4}" 中的 :>4 表示右对齐占4位)。
选择结构if...elif...else多分支处理难度选择和大小判断,三元表达式简化标签赋值。
循环结构while循环驱动反复猜测,for...in遍历历史记录,enumerate()同时获取索引和值,while...else判断是猜中退出还是次数耗尽。
异常处理try...except ValueError捕获非法输入,continue跳过本轮、break跳出循环。模块导入import random使用标准库的随机数功能。如果你把代码跑起来之后想继续折腾,这里有几个扩展方向:用json模块把游戏记录保存到文件里,下次打开还能看到历史成绩;加一个"排行榜"功能,记录每个难度的最佳成绩;或者用time模块计算玩家的思考时间。每多做一个功能,你对这些基础语法的掌握就会更扎实一层。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-22 01:57:34 HTTP/2.0 GET : https://f.mffb.com.cn/a/505141.html
  2. 运行时间 : 0.334938s [ 吞吐率:2.99req/s ] 内存消耗:4,683.64kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=8adde68d80330df785bf94c9f3d489d6
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000906s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001240s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000681s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000633s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001176s ]
  6. SELECT * FROM `set` [ RunTime:0.006000s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001535s ]
  8. SELECT * FROM `article` WHERE `id` = 505141 LIMIT 1 [ RunTime:0.080436s ]
  9. UPDATE `article` SET `lasttime` = 1787335054 WHERE `id` = 505141 [ RunTime:0.002289s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000722s ]
  11. SELECT * FROM `article` WHERE `id` < 505141 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001336s ]
  12. SELECT * FROM `article` WHERE `id` > 505141 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001122s ]
  13. SELECT * FROM `article` WHERE `id` < 505141 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.014241s ]
  14. SELECT * FROM `article` WHERE `id` < 505141 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.053929s ]
  15. SELECT * FROM `article` WHERE `id` < 505141 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002156s ]
0.339567s