当前位置:首页>python>Python difflib库详解:文本差异比较与合并实战指南

Python difflib库详解:文本差异比较与合并实战指南

  • 2026-07-02 16:44:56
Python difflib库详解:文本差异比较与合并实战指南

Python difflib库详解:文本差异比较与合并实战指南

  • 一、Python difflib库详解
    • 1、 引言:为什么需要文本差异比较?
    • 2、 核心类与方法概览
    • 3、基础比较:SequenceMatcher 与相似度计算
      • 3.1、 基本使用
      • 3.2 、理解匹配块与差异
    • 4、生成可读的差异报告
      • 4.1 、使用 Differ 类
      • 4.2、 生成 Unified Diff(最常用)
      • 4.3 、生成 Context Diff
    • 5、 高级应用:生成 HTML 差异报告
    • 6、实用技巧与函数
      • 6.1 、模糊匹配:get_close_matches
      • 6.2 、忽略“垃圾”字符
    • 7、 实战案例:一个简单的文件差异比较工具
    • 8、 总结
  • 二、代码示例
    • 1、示例代码
    • 2、运行结果

一、Python difflib库详解

1、 引言:为什么需要文本差异比较?

在日常开发、代码审查、文档协作和日志分析中,我们经常需要比较两个文本的差异。手动逐行比对不仅效率低下,而且容易出错。Python 标准库中的 difflib 模块正是为解决这一问题而生,它提供了一系列强大的工具,用于计算序列(尤其是字符串序列)之间的差异,并以多种直观的格式展示结果。

difflib 的核心算法基于 “最长公共子序列” 和 “Ratcliff/Obershelp 模式识别”,能够高效地找出文本的增、删、改操作。无论是生成代码补丁、对比配置文件版本,还是实现一个简单的在线文本差异查看器,difflib 都是你的得力助手。

2、 核心类与方法概览

difflib 模块主要提供了以下几个类和函数:

类/函数
主要用途
输出格式
difflib.SequenceMatcher
计算两个序列的相似度与差异块
原始差异数据
difflib.Differ
逐行比较文本,生成类 Unix diff 命令的输出
带 +-? 标记的文本
difflib.HtmlDiff
生成高亮的 HTML 差异报告,适合网页展示
HTML 表格
difflib.unified_diff
生成 Unified Diff 格式的差异,广泛用于代码版本控制
Unified Diff 文本
difflib.context_diff
生成 Context Diff 格式的差异
Context Diff 文本
difflib.ndiff
类似 Differ,但输出更紧凑
紧凑的差异文本
difflib.get_close_matches
在列表中查找与目标词最相似的匹配项
匹配字符串列表

接下来,我们将逐一深入探讨。

3、基础比较:SequenceMatcher 与相似度计算

SequenceMatcher 是 difflib 的基石。它不直接生成可读的差异报告,而是计算出两个序列之间的匹配块,并提供了计算相似度比率的方法。

3.1、 基本使用

import difflibtext1 = "Python is great for data analysis."text2 = "Python is great for web development and data analysis."# 创建 SequenceMatcher 对象matcher = difflib.SequenceMatcher(None, text1, text2)# 计算相似度比率 (0.0 到 1.0)ratio = matcher.ratio()print(f"相似度比率: {ratio:.2f}")  # 输出: 相似度比率: 0.78# 获取匹配块# 每个块是一个三元组 (i, j, n),表示 text1[i:i+n] == text2[j:j+n]matching_blocks = matcher.get_matching_blocks()print("匹配块:")for block in matching_blocks:    i, j, n = block    if n:  # 忽略长度为 0 的块        print(f"  text1[{i}:{i+n}] == text2[{j}:{j+n}] -> '{text1[i:i+n]}'")

输出示例

C:\Users\徐鹏\Desktop\55\.venv\Scripts\python.exe C:\Users\徐鹏\Desktop\55\main.py 相似度比率: 0.77匹配块:  text1[0:20] == text2[0:20] -> 'Python is great for '  text1[20:34] == text2[40:54] -> 'data analysis.'进程已结束,退出代码为 0

3.2 、理解匹配块与差异

get_matching_blocks() 返回的是两个序列中完全相同的部分。差异部分则位于这些匹配块之间。SequenceMatcher 还提供了 get_opcodes() 方法,它能更清晰地告诉我们为了将序列 a 转换为序列 b 需要执行哪些操作。

a = ["apple""banana""cherry""date"]b = ["apple""blueberry""cherry""elderberry"]matcher = difflib.SequenceMatcher(None, a, b)opcodes = matcher.get_opcodes()print("操作码 (tag, i1, i2, j1, j2):")for tag, i1, i2, j1, j2 in opcodes:    print(f"  {tag:7} a[{i1}:{i2}] -> b[{j1}:{j2}]", end=" ")    if tag == 'equal':        print(f" (内容相同: {a[i1:i2]})")    elif tag == 'replace':        print(f" (将 {a[i1:i2]} 替换为 {b[j1:j2]})")    elif tag == 'delete':        print(f" (删除 {a[i1:i2]})")    elif tag == 'insert':        print(f" (插入 {b[j1:j2]})")

输出示例:

操作码 (tag, i1, i2, j1, j2):  equal   a[0:1] -> b[0:1]  (内容相同: ['apple'])  replace a[1:2] -> b[1:2]  (将 ['banana'] 替换为 ['blueberry'])  equal   a[2:3] -> b[2:3]  (内容相同: ['cherry'])  replace a[3:4] -> b[3:4]  (将 ['date'] 替换为 ['elderberry'])

4、生成可读的差异报告

SequenceMatcher 提供了底层数据,但通常我们需要更直观的输出。Differunified_diff 和 context_diff 就是为此设计的。

4.1 、使用 Differ 类

Differ 生成的行级差异标记与 Unix diff 命令类似:

  • ' '
     (空格):两行相同
  • '-'
    :仅存在于第一个序列(被删除)
  • '+'
    :仅存在于第二个序列(被添加)
  • '?'
    :指示行内具体字符的增删(需要设置 linejunk 和 charjunk 参数为 None 来启用)
from difflib import Differtext1_lines = [    "def hello_world():",    "    print('Hello, World!')",    "    return True"]text2_lines = [    "def hello_world():",    "    print('Hello, Python!')",    "    x = 1 + 2",    "    return True"]d = Differ()diff = list(d.compare(text1_lines, text2_lines))print("Differ 比较结果:")for line in diff:    # 根据前缀添加颜色或样式(此处用符号表示)    if line.startswith('-'):        print(f"\033[91m{line}\033[0m")  # 红色表示删除    elif line.startswith('+'):        print(f"\033[92m{line}\033[0m")  # 绿色表示新增    elif line.startswith('?'):        print(f"\033[93m{line}\033[0m")  # 黄色表示行内变化提示    else:        print(line)

输出示例:

4.2、 生成 Unified Diff(最常用)

Unified Diff 格式是 Git 等版本控制系统使用的标准补丁格式。它非常紧凑,包含了上下文行。

from difflib import unified_diffimport sys# 假设我们有两个版本的代码片段original = """def calculate_sum(a, b):    result = a + b    print(f"The sum is {result}")    return result"""modified = """def calculate_sum(a, b):    # 计算两数之和    total = a + b    print(f"The sum is {total}")    return total"""diff_lines = unified_diff(    original.splitlines(keepends=True),    modified.splitlines(keepends=True),    fromfile='original.py',    tofile='modified.py',    lineterm='\n'  # 确保行尾是换行符)print("Unified Diff 格式:")sys.stdout.writelines(diff_lines)

输出示例:

--- original.py+++ modified.py@@ -1,5 +1,6 @@ def calculate_sum(a, b):-    result = a + b+    # 计算两数之和+    total = a + b-    print(f"The sum is {result}")+    print(f"The sum is {total}")-    return result+    return total
  • @@ -1,5 +1,6 @@
     表示原始文件从第1行开始的5行,被修改为从第1行开始的6行。
  • -
     开头的行表示在原始文件中被删除。
  • +
     开头的行表示在新文件中被添加。

4.3 、生成 Context Diff

Context Diff 格式比 Unified Diff 更冗长,但提供了更多上下文,曾经是 patch 命令的默认格式。

from difflib import context_diffdiff = context_diff(    a=original.splitlines(keepends=True),    b=modified.splitlines(keepends=True),    fromfile='old_version',    tofile='new_version',)print("Context Diff 格式 (前几行):")for i, line in enumerate(diff):    if i > 15:  # 只打印一部分        break    print(line, end='')

5、 高级应用:生成 HTML 差异报告

HtmlDiff 类可以生成一个完整的 HTML 页面,用颜色高亮显示差异,非常适合集成到 Web 应用中。

from difflib import HtmlDiffhtml_diff = HtmlDiff(wrapcolumn=60)  # wrapcolumn 可控制换行宽度# 生成 HTML 表格html_table = html_diff.make_table(    fromlines=original.splitlines(),    tolines=modified.splitlines(),    fromdesc='原始版本',    todesc='修改版本',    context=True,  # 显示上下文    numlines=3     # 上下文的行数)# 生成完整 HTML 页面full_html = html_diff.make_file(    fromlines=original.splitlines(),    tolines=modified.splitlines(),    fromdesc='Original',    todesc='Modified')# 将 HTML 保存到文件,方便查看with open('diff_report.html''w', encoding='utf-8'as f:    f.write(full_html)print("HTML 差异报告已生成到 'diff_report.html',请在浏览器中打开查看。")

生成的 HTML 页面会以并排表格的形式展示,新增行为绿色背景,删除行为红色背景,修改行则会有黄底色提示,非常直观。

6、实用技巧与函数

6.1 、模糊匹配:get_close_matches

get_close_matches 是一个非常实用的函数,它能在列表中快速找到与目标词最相似的几个匹配项。其核心是 SequenceMatcher.ratio()

from difflib import get_close_matchescandidates = ['apple''application''apply''appliance''banana''cherry']word = 'appel'# 找出前3个最相似的词matches = get_close_matches(word, candidates, n=3, cutoff=0.6)print(f"与 '{word}' 最相似的词: {matches}")# 输出: 与 'appel' 最相似的词: ['apple', 'apply', 'application']# 应用场景:命令行工具的命令纠错available_commands = ['start''stop''status''restart''config']user_input = 'statu'suggestion = get_close_matches(user_input, available_commands, n=1, cutoff=0.5)if suggestion:    print(f"您想输入的是 '{suggestion[0]}' 吗?")

输出示例

与 'appel' 最相似的词: ['apply''apple']您想输入的是 'status' 吗?

6.2 、忽略“垃圾”字符

在比较时,有时我们希望忽略空格、标点或特定字符。可以通过自定义 isjunk 函数来实现。

import difflibimport stringdef ignore_punctuation_and_space(s):    """移除标点和空格"""    return s.translate(str.maketrans('''', string.punctuation + ' '))text1 = "Hello, world!"text2 = "Hello world"matcher = difflib.SequenceMatcher(    lambda x: x in " ,!",  # isjunk 函数:认为空格、逗号、叹号是“垃圾”    text1,    text2)print(f"忽略部分字符后的相似度: {matcher.ratio():.2f}")  # 可能更高# 另一种方式:预处理文本clean1 = ignore_punctuation_and_space(text1)clean2 = ignore_punctuation_and_space(text2)matcher2 = difflib.SequenceMatcher(None, clean1, clean2)print(f"完全清理后的相似度: {matcher2.ratio():.2f}")

输出示例

忽略部分字符后的相似度: 0.92完全清理后的相似度: 1.00

7、 实战案例:一个简单的文件差异比较工具

让我们综合运用以上知识,构建一个命令行文件比较工具。

#!/usr/bin/env python3"""file_diff_tool.py - 一个简单的文件差异比较工具用法: python file_diff_tool.py <file1> <file2> [--format {unified,context,html}]"""import difflibimport argparseimport sysdef compare_files(file1_path, file2_path, diff_format='unified'):    """比较两个文件并输出差异"""    try:        with open(file1_path, 'r', encoding='utf-8'as f1, \             open(file2_path, 'r', encoding='utf-8'as f2:            lines1 = f1.readlines()            lines2 = f2.readlines()    except FileNotFoundError as e:        print(f"错误: 文件未找到 - {e}", file=sys.stderr)        return False    except UnicodeDecodeError:        print("错误: 文件编码可能不是 UTF-8,请尝试其他编码。", file=sys.stderr)        return False    if diff_format == 'unified':        diff_lines = difflib.unified_diff(            lines1, lines2,            fromfile=file1_path,            tofile=file2_path,            lineterm='\n'        )        sys.stdout.writelines(diff_lines)    elif diff_format == 'context':        diff_lines = difflib.context_diff(            lines1, lines2,            fromfile=file1_path,            tofile=file2_path,            lineterm='\n'        )        sys.stdout.writelines(diff_lines)    elif diff_format == 'html':        html_diff = difflib.HtmlDiff()        html_content = html_diff.make_file(            lines1, lines2,            fromdesc=file1_path,            todesc=file2_path,            context=True        )        output_file = f"diff_{file1_path}_{file2_path}.html"        with open(output_file, 'w', encoding='utf-8'as f:            f.write(html_content)        print(f"HTML 差异报告已生成: {output_file}")    else:        print(f"不支持的格式: {diff_format}", file=sys.stderr)        return False    return Truedef main():    parser = argparse.ArgumentParser(description='比较两个文本文件的差异')    parser.add_argument('file1'help='第一个文件路径')    parser.add_argument('file2'help='第二个文件路径')    parser.add_argument('--format', choices=['unified''context''html'],                        default='unified'help='差异输出格式 (默认: unified)')    args = parser.parse_args()    success = compare_files(args.file1, args.file2, args.format)    sys.exit(0 if success else 1)if __name__ == '__main__':    main()

使用示例:

# 生成 Unified Diffpython file_diff_tool.py old_code.py new_code.py# 生成 Context Diffpython file_diff_tool.py old_code.py new_code.py --format context# 生成 HTML 报告python file_diff_tool.py old_code.py new_code.py --format html

8、 总结

difflib 是 Python 标准库中一个强大而实用的模块,它使得文本差异比较变得简单高效。通过本文,你应该掌握了:

  1. 核心类与函数
    SequenceMatcherDifferHtmlDiffunified_diff 等的用途与区别。
  2. 差异格式
    :理解并能够生成 Unified Diff、Context Diff 和 HTML 报告。
  3. 实用技巧
    :使用 get_close_matches 进行模糊匹配,通过 isjunk 参数忽略无关字符。
  4. 实战应用
    :能够构建自己的文件比较工具或集成到其他应用中。

最佳实践建议:

  • 对于代码版本比较,优先使用 unified_diff,因为它最紧凑且被广泛支持。
  • 需要在 Web 页面展示差异时,HtmlDiff 是最佳选择。
  • 进行模糊搜索或拼写检查时,别忘了 get_close_matches
  • 处理大文件时,注意内存消耗,可以考虑逐块读取比较。

二、代码示例

1、示例代码

import difflib# 两段STM32链接脚本文本(和Rust示例一致)old_text = """STM32 linker script stack config.stack ALIGN(4) :{    _estack = .;    . += STACK_SIZE;} > RAMSupport float only"""new_text = """STM32 linker script stack config.stack ALIGN(8) :{    _estack = .;    . += STACK_SIZE;} > RAMSupport float & double with 8-byte align"""# 按行切分成列表old_lines = old_text.splitlines()new_lines = new_text.splitlines()print("=" * 60)print("1. 简易行对比(ndiff,带 +/- 标记)")print("=" * 60)diff_ndiff = difflib.ndiff(old_lines, new_lines)for line in diff_ndiff:    # 标记说明:- 删除行、+新增行、 不变行、?字符改动提示    if line.startswith("-"):        print(f"\033[31m{line}\033[0m")  # 红色删除    elif line.startswith("+"):        print(f"\033[32m{line}\033[0m")  # 绿色新增    else:        print(line)print("\n" + "=" * 60)print("2. Git风格 unified 补丁格式(可保存为.patch文件)")print("=" * 60)# context=2 上下文显示2行unified_diff = difflib.unified_diff(old_lines, new_lines, fromfile="original.ld", tofile="modified.ld", n=2)patch_content = "\n".join(unified_diff)print(patch_content)# 保存补丁到文件with open("stack_align.patch""w", encoding="utf-8"as f:    f.write(patch_content)print("\n补丁已保存至 stack_align.patch")print("\n" + "=" * 60)print("3. 单行内字符级精细对比(SequenceMatcher)")print("=" * 60)# 对比改动行:ALIGN(4) → ALIGN(8)old_line = ".stack ALIGN(4) :"new_line = ".stack ALIGN(8) :"sm = difflib.SequenceMatcher(None, old_line, new_line)output = []for tag, i1, i2, j1, j2 in sm.get_opcodes():    if tag == "equal":        output.append(old_line[i1:i2])    elif tag == "delete":        output.append(f"\033[31;9m{old_line[i1:i2]}\033[0m")    elif tag == "insert":        output.append(f"\033[32;1m{new_line[j1:j2]}\033[0m")    elif tag == "replace":        output.append(f"\033[31;9m{old_line[i1:i2]}\033[0m")        output.append(f"\033[32;1m{new_line[j1:j2]}\033[0m")print("原行对比高亮:""".join(output))print("\n" + "=" * 60)print("4. 生成HTML可视化对比页面")print("=" * 60)html_diff = difflib.HtmlDiff(wrapcolumn=80)html_page = html_diff.make_file(old_lines, new_lines, fromdesc="原始ld脚本", todesc="修改后ld脚本")with open("diff_view.html""w", encoding="utf-8"as f:    f.write(html_page)print("可视化对比页面已保存 diff_view.html,浏览器打开即可查看")

2、运行结果

============================================================1. 简易行对比(ndiff,带 +/- 标记)============================================================  STM32 linker script stack config- .stack ALIGN(4) :?              ^+ .stack ALIGN(8) :?              ^  {      _estack = .;      . += STACK_SIZE;  } > RAM- Support float only+ Support float & double with 8-byte align============================================================2. Git风格 unified 补丁格式(可保存为.patch文件)============================================================--- original.ld+++ modified.ld@@ -1,7 +1,7 @@ STM32 linker script stack config-.stack ALIGN(4) :+.stack ALIGN(8) : {     _estack = .;     . += STACK_SIZE; } > RAM-Support float only+Support float & double with 8-byte align补丁已保存至 stack_align.patch============================================================3. 单行内字符级精细对比(SequenceMatcher)============================================================原行对比高亮: .stack ALIGN(48) :============================================================4. 生成HTML可视化对比页面============================================================可视化对比页面已保存 diff_view.html,浏览器打开即可查看进程已结束,退出代码为 0

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 01:03:44 HTTP/2.0 GET : https://f.mffb.com.cn/a/502825.html
  2. 运行时间 : 0.163190s [ 吞吐率:6.13req/s ] 内存消耗:4,657.67kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=2c334c63c74a3a65d00c4cd0627058e7
  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.000537s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000802s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001126s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.001451s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000608s ]
  6. SELECT * FROM `set` [ RunTime:0.000611s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000737s ]
  8. SELECT * FROM `article` WHERE `id` = 502825 LIMIT 1 [ RunTime:0.005051s ]
  9. UPDATE `article` SET `lasttime` = 1783011824 WHERE `id` = 502825 [ RunTime:0.031796s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000370s ]
  11. SELECT * FROM `article` WHERE `id` < 502825 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.007037s ]
  12. SELECT * FROM `article` WHERE `id` > 502825 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.005214s ]
  13. SELECT * FROM `article` WHERE `id` < 502825 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.029771s ]
  14. SELECT * FROM `article` WHERE `id` < 502825 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.006169s ]
  15. SELECT * FROM `article` WHERE `id` < 502825 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000901s ]
0.164772s