当前位置:首页>python>第2.7章:快速学习Python的循环

第2.7章:快速学习Python的循环

  • 2026-08-18 23:11:48
第2.7章:快速学习Python的循环

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

使用 for 和 while 重复处理数据,并完成命令行聊天记录管理程序。

本节目标

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

  1. 1. 使用 for 遍历字符串、列表、字典和集合。
  2. 2. 使用 range() 和 enumerate() 生成序号。
  3. 3. 使用 while 重复执行未知次数的任务。
  4. 4. 使用 break 和 continue 控制循环。
  5. 5. 识别死循环、越界和循环中修改容器等常见问题。
  6. 6. 完成命令行聊天记录管理程序。

1. 为什么需要循环

没有循环时,显示三条消息可能写成:

messages = ["你好", "请解释循环", "谢谢"]

print
(messages[0])
print
(messages[1])
print
(messages[2])

这段代码只适用于恰好三条消息。循环可以对每个元素执行同一操作:

for message in messages:
    print
(message)

消息数量变化时,代码仍然有效。

2. for 循环

基本结构:

for 临时变量 in 可迭代对象:
    重复执行的代码

遍历字符串:

for character in "AI":
    print
(character)

遍历列表:

messages = ["你好", "请解释循环", "谢谢"]

for
 message in messages:
    print
(f"消息:{message}")

每轮循环中,message 依次指向列表中的一个元素。

循环结束后才执行取消缩进的代码:

for message in messages:
    print
(message)

print
("全部消息显示完毕")

3. range() 生成整数序列

for number in range(5):
    print
(number)

输出 0 到 4,不包含结束值 5

常见形式:

range(5)         # 0, 1, 2, 3, 4
range
(1, 5)      # 1, 2, 3, 4
range
(1, 10, 2)  # 1, 3, 5, 7, 9

重复固定次数:

for attempt in range(1, 4):
    print
(f"第 {attempt} 次尝试")

不需要循环变量时,通常使用下划线:

for _ in range(3):
    print
("正在重试")

4. enumerate() 同时获得序号和值

显示聊天历史时通常需要编号:

messages = ["你好", "什么是循环?", "谢谢"]

for
 index, message in enumerate(messages, start=1):
    print
(f"{index}. {message}")

start=1 只改变显示序号,不会改变列表真实索引。列表第一项仍然是 messages[0]

不要为了取得索引而优先写复杂的 range(len(...))

for index in range(len(messages)):
    print
(index + 1, messages[index])

它可以工作,但只需要“序号和值”时,enumerate() 更清楚。

5. 遍历字典

message = {
    "role"
: "user",
    "content"
: "请解释循环",
}

直接遍历得到键:

for key in message:
    print
(key)

同时取得键和值:

for key, value in message.items():
    print
(f"{key}: {value}")

遍历聊天消息列表:

messages = [
    {"role": "user", "content": "你好"},
    {"role": "assistant", "content": "你好!"},
]

for
 index, message in enumerate(messages, start=1):
    role = message["role"]
    content = message["content"]
    print
(f"{index}. [{role}] {content}")

6. 遍历集合

keywords = {"Python", "AI", "循环"}

for
 keyword in keywords:
    print
(keyword)

不能依赖集合的遍历顺序。需要稳定显示时先排序:

for keyword in sorted(keywords):
    print
(keyword)

7. while 循环

while 在条件为真时持续执行:

count = 1

while
 count <= 3:
    print
(f"第 {count} 轮")
    count += 1

执行过程:

  1. 1. 检查 count <= 3
  2. 2. 条件为真,执行循环体。
  3. 3. count += 1 更新状态。
  4. 4. 回到顶部重新检查。
  5. 5. 条件为假时结束。

如果忘记更新 count,循环可能永远无法结束。

8. break 主动结束循环

菜单程序不知道用户要输入多少次,因此常使用无限循环,再通过 break 退出:

while True:
    command = input("输入命令,exit 退出:").strip().lower()

    if
 command == "exit":
        print
("程序结束")
        break


    print
(f"收到命令:{command}")

break 只结束它所在的最内层循环。

9. continue 跳过当前轮

while True:
    question = input("请输入问题,exit 退出:").strip()

    if
 question.lower() == "exit":
        break


    if
 not question:
        print
("问题不能为空")
        continue


    print
(f"已保存:{question}")

空输入时执行 continue,立即回到循环开头,不执行后面的保存逻辑。

continue 适合先排除无效情况,让主要逻辑减少嵌套。

10. 循环中的统计

统计角色数量:

messages = [
    {"role": "user", "content": "你好"},
    {"role": "assistant", "content": "你好!"},
    {"role": "user", "content": "什么是循环?"},
]

role_counts = {}

for
 message in messages:
    role = message["role"]
    role_counts[role] = role_counts.get(role, 0) + 1

print
(role_counts)

每轮读取旧计数,增加 1,再写回字典。

按关键词搜索:

keyword = "循环"
match_count = 0

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

    if
 keyword.lower() in content.lower():
        print
(content)
        match_count += 1

print
(f"找到 {match_count} 条")

11. 嵌套循环

循环内部可以再循环:

conversations = [
    ["你好", "你好!"],
    ["什么是列表?", "列表是可变序列。"],
]

for
 conversation_index, conversation in enumerate(conversations, start=1):
    print
(f"会话 {conversation_index}")

    for
 message in conversation:
        print
(f"- {message}")

内层循环会对外层每一项完整执行一次。嵌套过多会让代码难以阅读,先确认数据是否真的需要多层结构。

12. for 与 while 如何选择

场景
推荐
处理列表中的每条消息
for
重复固定次数
for
 + range()
遍历字典字段
for
持续运行直到用户退出
while
条件满足前持续重试
while

简单判断:

  • • 已知要遍历什么或重复多少次,优先 for
  • • 只知道继续条件,不知道次数,使用 while

13. 常见循环问题

死循环

count = 1

while
 count <= 3:
    print
(count)

count 没有变化,条件一直为真。修复为:

count += 1

range() 结束值不包含

range(1, 4) 是 1、2、3,不是 1、2、3、4

在遍历时修改同一个列表

numbers = [1, 2, 3, 4]

for
 number in numbers:
    if
 number % 2 == 0:
        numbers.remove(number)

这种写法可能跳过元素。当前章节可以创建新列表:

odd_numbers = []

for
 number in numbers:
    if
 number % 2 != 0:
        odd_numbers.append(number)

变量名混淆

for message in messages:
    print
(messages)

这会每轮打印整个列表。需要当前项时应该打印 message

循环外误用结果

如果列表为空,循环体一次也不会执行。不要假设循环中的变量一定被赋值:

messages = []

for
 message in messages:
    last_message = message

# print(last_message)  # 变量可能不存在

14. 章节项目:命令行聊天记录

创建 chat_history_cli.py

messages = []
allowed_roles = ("user", "assistant", "system")

print
("聊天记录管理器")

while
 True:
    print
("\n1. 添加消息")
    print
("2. 查看历史")
    print
("3. 搜索消息")
    print
("4. 查看统计")
    print
("5. 清空历史")
    print
("0. 退出")

    command = input("请选择功能:").strip()

    if
 command == "1":
        role = input("角色 user/assistant/system:").strip().lower()

        if
 role not in allowed_roles:
            print
("角色无效")
            continue


        content = input("消息内容:").strip()

        if
 not content:
            print
("消息不能为空")
            continue


        messages.append({
            "role"
: role,
            "content"
: content,
        })
        print
("消息已保存")

    elif
 command == "2":
        if
 not messages:
            print
("暂无历史消息")
            continue


        for
 index, message in enumerate(messages, start=1):
            print
(f"{index}. [{message['role']}] {message['content']}")

    elif
 command == "3":
        keyword = input("搜索关键词:").strip()

        if
 not keyword:
            print
("关键词不能为空")
            continue


        match_count = 0

        for
 index, message in enumerate(messages, start=1):
            if
 keyword.lower() in message["content"].lower():
                print
(f"{index}. [{message['role']}] {message['content']}")
                match_count += 1

        print
(f"共找到 {match_count} 条消息")

    elif
 command == "4":
        role_counts = {}

        for
 message in messages:
            role = message["role"]
            role_counts[role] = role_counts.get(role, 0) + 1

        print
(f"消息总数:{len(messages)}")

        for
 role in allowed_roles:
            print
(f"{role}: {role_counts.get(role, 0)}")

    elif
 command == "5":
        confirmation = input("确认清空?输入 yes:").strip().lower()

        if
 confirmation == "yes":
            messages.clear()
            print
("历史已清空")
        else
:
            print
("已取消")

    elif
 command == "0":
        print
("再见!")
        break


    else
:
        print
("无效选项,请重新输入")

运行:

python chat_history_cli.py

至少测试:

  1. 1. 空历史时查看。
  2. 2. 添加合法消息。
  3. 3. 添加空消息。
  4. 4. 输入无效角色。
  5. 5. 搜索存在和不存在的关键词。
  6. 6. 查看统计。
  7. 7. 取消清空和确认清空。
  8. 8. 输入无效菜单项。
  9. 9. 正常退出。

15. 当前版本的边界

程序退出后,messages 中的数据会消失,因为它只保存在内存中。这不是 Bug,而是当前版本的范围。

后续章节会逐步加入:

  • • 函数与模块,拆分过长代码。
  • • 异常处理,处理非法数字和文件错误。
  • • JSON 文件,持久化聊天历史。
  • • 类与数据模型,封装会话。
  • • HTTP 与大模型 API,获得真实回复。

动手练习

练习 1:消息编号

使用 enumerate() 输出:

1. [user] 你好
2. [assistant] 你好!

练习 2:去重且保留顺序

给定:

tags = ["Python", "AI", "Python", "入门", "AI"]

使用循环创建 unique_tags 列表,要求结果保留首次出现顺序:

["Python", "AI", "入门"]

练习 3:完成章节项目

手写并测试 chat_history_cli.py。不要只复制示例;至少增加一个功能,例如:

  • • 删除最后一条消息。
  • • 只查看某个角色的消息。
  • • 显示最长消息。
  • • 使用 exit 作为额外退出命令。

随堂小测

  1. 1. for 和 while 分别适合什么场景?
  2. 2. range(1, 5) 会生成哪些整数?
  3. 3. enumerate(messages, start=1) 的 start 会改变列表索引吗?
  4. 4. break 与 continue 有什么区别?
  5. 5. 为什么遍历列表时不推荐直接删除其中的元素?
  6. 6. 如何判断 while 是否可能成为死循环?
  7. 7. 搜索消息时为什么常把关键词和内容都转为小写?

参考答案

  1. 1. for 适合遍历已有数据或固定次数;while 适合次数未知、由条件决定是否继续的任务。
  2. 2. 1、2、3、4
  3. 3. 不会,只改变生成的显示序号。
  4. 4. break 结束整个当前循环;continue 跳过当前轮剩余代码,进入下一轮。
  5. 5. 列表长度和位置在遍历过程中改变,可能导致元素被跳过或结果难以预测。
  6. 6. 检查循环条件是否可能变为假,或是否存在能执行到的 break
  7. 7. 实现不区分大小写的匹配。

本节完成检查

  • • 我能使用 for 遍历四种容器。
  • • 我会使用 range() 和 enumerate()
  • • 我能使用 while 实现持续菜单。
  • • 我理解 break 和 continue
  • • 我能识别常见死循环和容器修改问题。
  • • 我完成并测试了聊天记录管理程序。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 17:26:34 HTTP/2.0 GET : https://f.mffb.com.cn/a/509329.html
  2. 运行时间 : 0.215907s [ 吞吐率:4.63req/s ] 内存消耗:4,849.02kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=a5695bf9e431d5f6a6f3b57507f065c8
  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.000957s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001847s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000780s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000708s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001648s ]
  6. SELECT * FROM `set` [ RunTime:0.000639s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001806s ]
  8. SELECT * FROM `article` WHERE `id` = 509329 LIMIT 1 [ RunTime:0.001408s ]
  9. UPDATE `article` SET `lasttime` = 1787304394 WHERE `id` = 509329 [ RunTime:0.009612s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000674s ]
  11. SELECT * FROM `article` WHERE `id` < 509329 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001181s ]
  12. SELECT * FROM `article` WHERE `id` > 509329 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001078s ]
  13. SELECT * FROM `article` WHERE `id` < 509329 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.006089s ]
  14. SELECT * FROM `article` WHERE `id` < 509329 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002328s ]
  15. SELECT * FROM `article` WHERE `id` < 509329 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.004622s ]
0.219876s