当前位置:首页>python>Python itertools 修炼指南

Python itertools 修炼指南

  • 2026-07-02 16:48:34
Python itertools 修炼指南
# 读取一个 500 万行的日志文件,提取所有 ERROR 级别的记录# —— 这是你以前可能会写的代码errors = []with open("app.log""r"as f:for line in f:if"ERROR"in line:            errors.append(line.strip())# 列表塞满了,内存吃紧了,机器风扇开始转了……

你有没有经历过这种场景?数据量一大,你的 Python 进程慢下来,内存呼呼往上涨。然后你开始纠结——要不要上 Pandas?是不是该换数据库?其实不用。

Python 标准库里就藏着一个"轻量级神器",能让你的数据处理代码又快又省内存。

来看看它长什么样。

from itertools import islice, takewhile, count# 生成 20 以内所有 3 的倍数result = list(takewhile(lambda x: x <= 20, count(33)))# 输出:[3, 6, 9, 12, 15, 18]

看到没?两行代码,没有 for 循环,没有中间变量,没有列表推导式的嵌套地狱。count 无限地数数,takewhile 在条件不满足时自动刹车,整个过程数据是一个一个"流"过去的——不产生中间大列表。

这个模块叫 itertools,Python 标准库里的"低调贵族"。它的设计哲学用一个词总结就是:「迭代器代数」——把简单的迭代器操作像乐高积木一样拼起来,就能搭出复杂的数据处理管道。

而你只需要学会怎么搭。


不过,刚才的例子多少有点"玩具感"。真正到项目里,你会发现需求远没有那么单纯。

假设你现在真的在处理刚才那个 500 万行的日志文件。需求来了:

  • 过滤出 「ERROR」 和 「WARNING」 级别的日志
  • 按时间戳排序(日志是按时间顺序写的,但多线程写入时可能有乱序)
  • 每 100 条打包一批,批量写入数据库
  • 对连续 5 次以上出现的相同错误,标记为"风暴"事件
日志分析界面

你拿起键盘,第一反应是什么?

如果你下意识地开始写 for line in file: 然后塞一堆 if-else……坦白说,这条代码写到第 50 行的时候,你自己都不想看了。

我们用最直观的方式写一下这个逻辑的核心片段:

# 直觉写法的雏形from collections import defaultdicterrors = []with open("app.log"as f:for line in f:if"ERROR"in line or"WARNING"in line:            parts = line.strip().split(" | ")            errors.append(parts)# 排序errors.sort(key=lambda x: x[0])  # 按时间戳# 分批batches = [errors[i:i+100for i in range(0, len(errors), 100)]# 检测风暴# ... 又要写一大段循环嵌套

这样的代码能跑,但你有没有觉得哪里不对劲?


先不说可读性,单说性能:errors 这个列表把 500 万行日志全吞进内存了——即便过滤后只有 100 万行,每行假设 200 字节,那也是 「200MB 内存」

而且这只是第一版。需求一变,你就要在巨长的函数里加 if。一周之后你回头看自己的代码,已经分不清哪个 if 对应哪个需求了。

用 itertools 的时候,还有几个坑等着你。来看看最常见的"死亡陷阱":

陷阱一:无限迭代器没有"刹车片"

from itertools import countfor i in count(102):    print(i)  # 10, 12, 14, 16 ... 永远不会停

你以为它会在你不需要的时候自动停下来吗?不会。count 会忠实地数到天荒地老。

陷阱二:groupby 不是你想的那样

from itertools import groupbydata = [132312]  # 没有排序for key, group in groupby(data):    print(key, list(group))# 输出的是:# 1 [1]# 3 [3]# 2 [2]# 3 [3]# 1 [1]# 2 [2]# 你想要的可能是:按值分组 → 1:[1,1], 2:[2,2], 3:[3,3]

「不是所有相同的值都分到了一起」——groupby 只认"连续相同",不认"全局相同"。很多人第一次用的时候都栽过这个跟头。

陷阱三:迭代器是一次性消耗品

from itertools import cycle, islicecolors = cycle(["red""green""blue"])first = list(islice(colors, 3))   # ✅ ['red', 'green', 'blue']second = list(islice(colors, 3))  # ❌ 不是 ['red', 'green', 'blue'] 吗?# 实际上是 ['red', 'green', 'blue'] ... 等等,它是对的,但是从上次消耗的位置继续取的

等等,我刚才说"是对的"?让我再想想——cycle 是无限循环,所以 second 确实能取到值。但假设你换成了 iter(range(10)),第一次 islice(it, 8) 消耗了前 8 个,第二次 islice(it, 3) 只能拿到后 2 个了。

迭代器就像公交车——坐过站了不能倒回去。很多人以为它在手就能随时从头再来,然后 debug 到怀疑人生。


好,坑你也知道了。现在来看看真正的解法。

回到那个日志分析的场景,我们用 itertools 来重新组织代码。你会发现整个逻辑变成了一组「声明式的管道」,而不是嵌套的循环和条件。

第一步:惰性过滤,不占内存

from itertools import filterfalsedefis_error_level(line):return"ERROR"in line or"WARNING"in line# 过滤出目标行 —— 不产生列表,返回的是迭代器filtered_lines = filter(is_error_level, open("app.log"))# 注意:filter 是内置函数,不是 itertools,但它也返回迭代器# 如果想用 itertools 风格,可以用 filterfalse 的反向思维

这里的关键差异:open("app.log") 本身返回的是一个文件迭代器(逐行读取),filter 包一层之后,每次迭代「才读一行、判断一行」,而不是先读完再过滤。500 万行文件的峰值内存 = 「一行的大小」

第二步:用 groupby 做风暴检测

先排序,再分组——记住这个口诀:

from itertools import groupby# 模拟一组日志消息(已按时间排序)log_messages = ["2026-06-29 10:00:01 | ERROR | 数据库连接超时","2026-06-29 10:00:02 | ERROR | 数据库连接超时","2026-06-29 10:00:03 | ERROR | 数据库连接超时","2026-06-29 10:00:04 | INFO | 健康检查通过","2026-06-29 10:00:05 | ERROR | 数据库连接超时","2026-06-29 10:00:06 | ERROR | 数据库连接超时",]defextract_message(line):"""提取日志内容(按 '|' 分隔取第三段)"""return line.strip().split(" | ")[-1]# 按内容分组(前提:数据已按内容排序或至少连续相同)for content, group in groupby(log_messages, key=extract_message):    group_list = list(group)    count = len(group_list)if count >= 3:        print(f"⚡ 风暴检测:'{content}' 连续出现了 {count} 次")# 输出:⚡ 风暴检测:'数据库连接超时' 连续出现了 3 次

注意到没有?groupby 处理连续出现的元素正是它最擅长的——这不就是"连续 5 次以上相同错误"的天然解法吗?

⚠️ 但等一下,别忘了陷阱——上面的数据恰好是"连续"的。如果你的数据出现了 [A, A, B, A, A]groupby 会把两个 A 段分开处理。你需要先用 sorted() 对 key 排序,才能确保全局分组。

第三步:islice + 迭代器引用,实现无内存分批

from itertools import islicedefbatch_iterator(iterable, batch_size):"""将迭代器按批切分,每次返回一个 batch"""    iterator = iter(iterable)whileTrue:        batch = list(islice(iterator, batch_size))ifnot batch:breakyield batch# 使用:分批写入数据库for batch in batch_iterator(filtered_lines, 100):    db_insert_batch(batch)  # 每批最多 100 条

这里用了一个精妙的手法:[iter(iterable)] * n 的技巧。不过上面的实现更直观——islice 每次从同一个迭代器"切"出 batch_size 个元素,因为迭代器是有状态的,每次调用都会从上次停下的地方继续。

test

第四步:chain 无限序列,优雅地构造带标签的数据

from itertools import chain, count, islicedefbatch_iterator_v2(iterable, batch_size):"""给每批数据加上批次号"""    iterator = iter(iterable)    batch_index = count(1)whileTrue:        batch = list(islice(iterator, batch_size))ifnot batch:breakyield next(batch_index), batch# 使用:直接拿到 (批次号, 数据列表)for idx, batch in batch_iterator_v2(filtered_lines, 100):    print(f"正在写入第 {idx} 批,共 {len(batch)} 条")    db_insert_batch(batch)

chain 则是连接多个可迭代对象的利器,比如你想在日志流之前加一个"表头行":

from itertools import chainheader = ["时间戳 | 级别 | 消息"]log_stream = chain(header, filtered_lines)# 输出时第一行是表头,后面是数据行

第五步:数据分块——zip_longest 的高级玩法

还记得那个"取迭代器引用然后 islice 切"的分批方法吗?还有一个更优雅的方式:

from itertools import zip_longestdefchunked(iterable, n, fillvalue=None):"""将可迭代对象分成大小为 n 的块"""    args = [iter(iterable)] * nreturn zip_longest(*args, fillvalue=fillvalue)data = range(10)for chunk in chunked(data, 3):    print(chunk)# (0, 1, 2)# (3, 4, 5)# (6, 7, 8)# (9, None, None)

这里 [iter(iterable)] * n 创建了 「n 个指向同一个迭代器的引用」zip_longest 每次从每个引用取一个元素,于是自然完成了"一次取 n 个"。加上 fillvalue 参数,最后不完整的块也能妥善处理。

第六步:tee 复制迭代器,一鱼多吃

有时你需要把同一个数据源"分流"到不同的处理管道:

from itertools import tee, islicedefanalyze_logs(log_iterator):"""对同一份日志流做多维度分析"""# 复制出 3 个独立的迭代器    stream_for_stats, stream_for_errors, stream_for_archive = tee(log_iterator, 3)# 管道 1:统计级别分布(每 1000 条统计一次)    stats = analyze_level_distribution(stream_for_stats)# 管道 2:实时警报(只看 ERROR)    alerts = detect_critical_errors(stream_for_errors)# 管道 3:归档(全量写入)    archive_logs(stream_for_archive)return stats, alerts

⚠️ 注意:tee 不是免费的——它用额外的内存缓存元素来支持多个迭代器的独立迭代。数据量极大时,要么控制并行管道的数量,要么确保各个管道的消费速度相差不大,否则缓存会膨胀。

回过头来看,完整的日志分析管道:

from itertools import (    filterfalse, groupby, islice, chain, count, takewhile)defanalyze_log_pipeline(log_path):"""完整的日志分析管道,没有中间大列表"""# 步骤 1:逐行读取(已经是惰性的)    raw_lines = open(log_path)# 步骤 2:过滤目标级别defis_target_level(line):return any(level in line for level in ("ERROR""WARNING"))    target_lines = filter(is_target_level, raw_lines)# 步骤 3:按连续错误检测风暴defextract_error_msg(line):        parts = line.strip().split(" | ")return parts[-1if len(parts) >= 3else""    storm_events = []for msg, group in groupby(target_lines, key=extract_error_msg):        group_list = list(group)if len(group_list) >= 5:            storm_events.append((msg, len(group_list)))# 步骤 4:分批归档(需重新读取文件——迭代器已耗尽)# 在实际应用中,上面的 groupby 不会消耗太多数据# 更合理的方式是复用 tee 或在一步内完成return storm_events

你看,整个管道没有一次把数据全部加载到内存。每处理一行,消费一行。这才是处理"几百万行数据"的正确姿势——而且全部用的「标准库」,零依赖。


到这里,你已经体验了 itertools 最核心的实战场景。但工具箱远不止这些。它就像一个"瑞士军刀",你遇见的每个数据处理场景,几乎都能找到对应的工具:

  • product:多层嵌套循环的降维打击。当你在写 for a in listA: for b in listB: for c in listC: 时,product(listA, listB, listC) 一句替代三层缩进地狱。
  • permutations 与 combinations:枚举所有排列和组合,测试用例生成、密码暴力匹配、A/B 测试分组……信手拈来。
  • accumulate:不仅是累加和。传入 max 就是滑动最大值,传入 lambda 就是自定义累积逻辑——用一个函数替代一个循环。
  • starmap:当 map 不够用的时候。starmap(pow, [(2,3), (3,2)]) 等价于 [pow(2,3), pow(3,2)],参数自动解包。
  • pairwise:Python 3.10 新增。相邻元素配对,差值计算、滑动窗口的基础构件。
  • compress:用布尔列表快速筛选。"从字符串 A 中提取 B 中为 True 对应位置的字符",一行搞定。
  • dropwhile / takewhile:处理"跳过表头""截取到指定条件为止"这类场景,比手写循环条件清晰 10 倍。

每个函数都不复杂,但组合起来能做的事远超想象。

如果你想让代码再上一层楼,可以继续探索这几个方向:

  • 「迭代器管道模式」:把 itertools 链式调用封装成高阶函数,写出类似 Linux 管道的 process | filter | group | write 风格
  • 「与 functools 联合作战」:配合 partialreduce 等函数工具,让数据处理管道更加声明式
  • more-itertools 扩展库」:官方 itertools 的社区增强版,提供 chunkedwindowedbucket 等更高级的工具
  • 「惰性数据处理与微服务」:在异步框架(如 asyncio)中结合 itertools 实现流式数据处理微服务

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 01:03:14 HTTP/2.0 GET : https://f.mffb.com.cn/a/502882.html
  2. 运行时间 : 0.249792s [ 吞吐率:4.00req/s ] 内存消耗:4,545.42kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=b8d92c27ecb4604bb6572c70fabe5ee6
  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.001110s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001691s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000730s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000630s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001349s ]
  6. SELECT * FROM `set` [ RunTime:0.000539s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001448s ]
  8. SELECT * FROM `article` WHERE `id` = 502882 LIMIT 1 [ RunTime:0.001110s ]
  9. UPDATE `article` SET `lasttime` = 1783011794 WHERE `id` = 502882 [ RunTime:0.043651s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.008159s ]
  11. SELECT * FROM `article` WHERE `id` < 502882 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001338s ]
  12. SELECT * FROM `article` WHERE `id` > 502882 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001293s ]
  13. SELECT * FROM `article` WHERE `id` < 502882 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.060411s ]
  14. SELECT * FROM `article` WHERE `id` < 502882 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.008392s ]
  15. SELECT * FROM `article` WHERE `id` < 502882 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.008719s ]
0.253491s