当前位置:首页>python>第3.7章:快速学习Python的推导式、迭代器与生成器入门

第3.7章:快速学习Python的推导式、迭代器与生成器入门

  • 2026-08-20 06:56:54
第3.7章:快速学习Python的推导式、迭代器与生成器入门

《Python AI 应用开发入门》第 3.7 节。

使用推导式表达数据转换,理解迭代协议并用生成器按需处理数据。

本节目标

学完本节后,你应当能够:

  1. 1. 编写清晰的列表、字典和集合推导式。
  2. 2. 判断何时保留普通循环更容易阅读。
  3. 3. 区分可迭代对象与迭代器。
  4. 4. 使用 iter() 和 next() 观察迭代过程。
  5. 5. 理解 for 循环如何使用迭代协议。
  6. 6. 区分生成器表达式和列表推导式。
  7. 7. 使用 yield 编写生成器函数。
  8. 8. 按需搜索消息和逐块读取大文件。
  9. 9. 完成可配置、可持久化的模块化聊天程序。

1. 推导式解决什么问题

把所有消息内容转为列表:

contents = []for message in messages:    contents.append(message["content"])

列表推导式:

contents = [    message["content"]    for message in messages]

它表达“从每条消息取出内容,组成新列表”。

推导式适合单一、清楚的数据转换,不是为了让代码尽可能短。

2. 列表推导式

基本形式:

[结果表达式 for 临时变量 in 可迭代对象]

字符串清理:

raw_tags = [" Python ", " AI ", " RAG "]tags = [tag.strip() for tag in raw_tags]

带过滤条件:

user_messages = [    message    for message in messages    if message["role"] == "user"]

先过滤再转换:

user_contents = [    message["content"]    for message in messages    if message["role"] == "user"]

这里的条件放在末尾,表示只保留满足条件的项目。

3. 推导式中的条件表达式

需要对每项二选一时:

labels = [    "用户" if message["role"] == "user" else "其他"    for message in messages]

区别:

[value for value in values if condition]  # 过滤[a if condition else b for value in values]  # 每项转换

两者位置和含义不同。

4. 字典推导式

统计结果转换为显示标签:

role_counts = {    "user": 3,    "assistant": 2,}display_counts = {    role: f"{count} 条"    for role, count in role_counts.items()}

从配置中选择允许字段:

allowed_keys = {"model", "style", "max_history"}filtered_config = {    key: value    for key, value in config.items()    if key in allowed_keys}

如果多个项目产生相同键,后面的值会覆盖前面的值。设计键时要保证符合业务唯一性。

5. 集合推导式

得到不重复角色:

roles = {    message["role"]    for message in messages}

标准化标签并去除空值:

normalized_tags = {    tag.strip().lower()    for tag in raw_tags    if tag.strip()}

集合不保证业务显示顺序,需要展示时使用 sorted()

6. 何时不要使用推导式

下面的逻辑虽然可以塞进推导式,但不易读:

valid_messages = []for index, message in enumerate(messages, start=1):    try:        valid_messages.append(validate_message(message))    except ValueError as error:        print(f"跳过第 {index} 条:{error}")

它包含:

  • • 异常处理。
  • • 日志输出。
  • • 多个步骤。

保留普通循环更清楚。

经验规则:

  • • 一次简单转换或过滤:推导式。
  • • 多层嵌套、异常、多个副作用:普通循环。
  • • 读一遍不能立即说明含义:拆开。

7. 可迭代对象

可以逐项遍历的对象叫可迭代对象,例如:

  • • 字符串。
  • • 列表、元组。
  • • 字典、集合。
  • • range
  • • 文件对象。
  • • 生成器。

它们可以放在 for ... in ... 中:

for message in messages:    print(message)

“可迭代”不等于“支持索引”。集合和生成器可以迭代,但不能使用 values[0]

8. 迭代器

iter() 从可迭代对象获得迭代器:

messages = ["A", "B", "C"]iterator = iter(messages)print(next(iterator))print(next(iterator))print(next(iterator))

继续调用:

# next(iterator)

会触发 StopIteration,表示没有下一项。

可以提供默认值:

print(next(iterator, "没有更多消息"))

迭代器会记录当前位置。已经取出的项目不会自动重新出现。

9. for 循环与迭代协议

下面代码:

for message in messages:    print(message)

可以近似理解为:

iterator = iter(messages)while True:    try:        message = next(iterator)    except StopIteration:        break    print(message)

实际使用中让 for 自动处理 StopIteration。理解协议有助于理解文件、生成器和自定义迭代对象。

10. 迭代器只能继续向前

iterator = iter(["A", "B"])print(list(iterator))print(list(iterator))

第一次得到 ["A", "B"],第二次得到空列表,因为迭代器已经耗尽。

列表可以反复创建新迭代器:

messages = ["A", "B"]print(list(messages))print(list(messages))

收到迭代器或生成器时,不要在调试输出中先完整消费一遍,又期待后续逻辑还能读取。

11. 生成器表达式

把列表推导式的方括号换成圆括号:

lengths = (    len(message["content"])    for message in messages)

这不会立即创建包含全部长度的列表,而是返回生成器,使用时按需计算:

for length in lengths:    print(length)

对比:

length_list = [len(text) for text in contents]length_generator = (len(text) for text in contents)
  • • 列表立即保存全部结果,可重复遍历和索引。
  • • 生成器按需产生结果,占用内存更少,但通常只能消费一次。

数据量很小、需要反复使用时,列表更简单。

12. 生成器函数与 yield

函数中出现 yield,调用时会返回生成器:

def iter_user_messages(messages):    for message in messages:        if message["role"] == "user":            yield message

调用函数不会立即执行完整函数体:

user_messages = iter_user_messages(messages)

开始迭代时才运行。每次执行到 yield

  1. 1. 产生一个值。
  2. 2. 暂停并保留当前位置和局部变量。
  3. 3. 下次请求时从暂停处继续。
for message in user_messages:    print(message["content"])

13. 生成器中的 return

生成器执行 return 或到达函数末尾时停止:

def take_messages(messages, limit):    if limit <= 0:        return    for index, message in enumerate(messages):        if index >= limit:            return        yield message

这里的 return 不会像普通函数那样成为循环中的下一项,它表示生成结束。

14. 按需搜索消息

def search_messages(    messages: list[dict[str, str]],    keyword: str,):    normalized_keyword = keyword.strip().lower()    if not normalized_keyword:        return    for message in messages:        if normalized_keyword in message["content"].lower():            yield message

调用者可以只取第一个匹配:

matches = search_messages(messages, "Python")first_match = next(matches, None)

也可以全部遍历:

for message in search_messages(messages, "Python"):    print(message["content"])

类型注解可以写成 Iterator[dict[str, str]],需要从 collections.abc 导入:

from collections.abc import Iteratordef search_messages(    messages: list[dict[str, str]],    keyword: str,) -> Iterator[dict[str, str]]:    ...

15. 逐块读取大文件

from collections.abc import Iteratorfrom pathlib import Pathdef read_chunks(    path: Path,    chunk_size: int = 1024,) -> Iterator[str]:    if chunk_size <= 0:        raise ValueError("chunk_size 必须大于 0")    with path.open(mode="r", encoding="utf-8") as file:        while True:            chunk = file.read(chunk_size)            if not chunk:                break            yield chunk

使用:

for chunk in read_chunks(Path("large_notes.txt"), chunk_size=4096):    print(f"本块字符数:{len(chunk)}")

文件会在生成器迭代结束或生成器被关闭时离开 with。调用者不应创建后完全不消费并长期保存生成器。

16. 生成器的优势与限制

优势:

  • • 不必一次把全部结果放入内存。
  • • 可以边生产边处理。
  • • 能表达数据流。
  • • 调用者可以提前停止。

限制:

  • • 通常只能消费一次。
  • • 不能直接索引或获取长度。
  • • 错误可能在迭代时才发生,而不是创建生成器时。
  • • 对小数据可能比列表更难理解。

不要看到“大文件”就自动使用生成器。先确认是否真的需要按需处理。

17. 完成章节项目

最终结构:

stage2/└── chat_app/    ├── __init__.py    ├── main.py    ├── config.py    ├── prompts.py    ├── storage.py    └── data/        ├── config.json        ├── prompt_template.txt        └── history.json

职责:

  • • config.py:加载并验证 JSON 配置。
  • • prompts.py:读取模板并构造 Prompt。
  • • storage.py:验证、加载和安全保存历史。
  • • main.py:菜单、用户输入和异常边界。

main.py 的主流程:

def main() -> None:    try:        config = load_config(CONFIG_PATH)        messages = load_history(HISTORY_PATH)    except ValueError as error:        print(f"启动失败:{error}")        return    while True:        show_menu()        command = input("请选择:").strip()        if command == "1":            add_message_flow(messages, config)            save_history(HISTORY_PATH, messages)        elif command == "2":            display_messages(messages)        elif command == "3":            search_flow(messages)        elif command == "0":            print("再见")            break        else:            print("无效选项")

从 stage2 目录启动:

python -m chat_app.main

至少验证:

  1. 1. 首次运行没有历史文件。
  2. 2. 添加中文消息后生成 JSON。
  3. 3. 退出并重启后恢复消息。
  4. 4. 配置 JSON 损坏时明确失败。
  5. 5. 单条消息结构错误时指出序号。
  6. 6. 搜索能按需产生匹配结果。

动手练习

练习 1:三种推导式

从聊天历史中:

  • • 使用列表推导式取得用户消息内容。
  • • 使用集合推导式取得全部角色。
  • • 使用字典推导式生成“序号 → 内容”的映射。

练习 2:观察迭代器耗尽

对同一个迭代器连续调用 next(),再两次转换为列表。记录每一步结果并解释原因。

练习 3:完成章节项目

整合 7 节内容完成模块化聊天程序,并记录至少 10 个测试场景。

随堂小测

  1. 1. 推导式最适合什么逻辑?
  2. 2. 过滤条件和条件表达式在推导式中的位置有何不同?
  3. 3. 可迭代对象与迭代器有什么区别?
  4. 4. next() 在耗尽后会发生什么?
  5. 5. 为什么同一迭代器通常不能重复遍历?
  6. 6. 列表推导式与生成器表达式的主要区别是什么?
  7. 7. yield 会如何影响函数执行?
  8. 8. 生成器中的 return 表示什么?
  9. 9. 为什么生成器错误可能延迟到迭代时出现?

参考答案

  1. 1. 单一、清楚的数据转换或过滤。
  2. 2. 过滤条件放在 for 之后;二选一表达式写在结果位置并包含 else
  3. 3. 可迭代对象能创建迭代器;迭代器记录当前位置并通过 next() 逐项返回。
  4. 4. 默认触发 StopIteration,也可以给 next() 提供默认值。
  5. 5. 它会保存并推进当前位置,耗尽后没有项目可返回。
  6. 6. 列表立即保存全部结果;生成器按需计算,通常只能消费一次。
  7. 7. 调用返回生成器,迭代到 yield 时产生值并暂停,下次继续。
  8. 8. 停止生成。
  9. 9. 创建生成器时函数体尚未完整执行,相关代码在请求下一项时才运行。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 13:38:21 HTTP/2.0 GET : https://f.mffb.com.cn/a/510502.html
  2. 运行时间 : 0.440573s [ 吞吐率:2.27req/s ] 内存消耗:4,592.08kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=2dc2176d279e560e7757fa2969005f07
  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.000980s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001288s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.009369s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.017402s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001568s ]
  6. SELECT * FROM `set` [ RunTime:0.045124s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001790s ]
  8. SELECT * FROM `article` WHERE `id` = 510502 LIMIT 1 [ RunTime:0.014634s ]
  9. UPDATE `article` SET `lasttime` = 1787290701 WHERE `id` = 510502 [ RunTime:0.017939s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.050906s ]
  11. SELECT * FROM `article` WHERE `id` < 510502 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.012577s ]
  12. SELECT * FROM `article` WHERE `id` > 510502 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.016501s ]
  13. SELECT * FROM `article` WHERE `id` < 510502 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.004896s ]
  14. SELECT * FROM `article` WHERE `id` < 510502 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.076464s ]
  15. SELECT * FROM `article` WHERE `id` < 510502 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002138s ]
0.444010s