当前位置:首页>python>Python 开发必备:tempfile 模块深度解析

Python 开发必备:tempfile 模块深度解析

  • 2026-01-11 17:26:28
Python 开发必备:tempfile 模块深度解析

关注+星标,每天学习Python新技能

来源:网络

处理大数据集或者生成报告、创建中间文件的时候,很多文件其实根本不需要永久保存。这时候可以用临时目录来解决这个问题。Python 标准库里的 tempfile 模块能创建用完就自动消失的临时文件和目录,省去手动清理的麻烦。

临时目录就是个生命周期很短的文件夹,专门用来存放那些不需要长期保留的数据。用完之后连同里面的内容一起删掉,文件系统保持干净。

Python 的 tempfile 模块提供了一套完整的解决方案,这些临时文件和目录在不需要的时候会自动清理掉。

为什么要用临时目录

临时目录在实际开发中有几个明显的好处:

自动清理机制省去了手动删除的步骤,每个临时目录都有唯一标识避免文件名冲突。系统会自动选择安全的存储位置,Unix 系统用 /tmp,Windows 用 %TEMP%。多线程和多进程环境下也能稳定工作,特别适合测试场景和需要中间存储的情况。

什么场景下需要临时目录

需要一个临时空间来存放中间计算结果或临时文件。写单元测试的时候模拟文件操作,完了自动清理。下载或解压的数据不需要长期保存。处理用户上传的文件,在保存最终结果之前需要一个缓冲区。构建自动化流程时,要确保不留下任何痕迹。

tempfile 模块基础用法

import tempfile  import os  # Create a temporary directorywith tempfile.TemporaryDirectory() as temp_dir:      print(f"Temporary directory created at: {temp_dir}")      # Create a temporary file inside the directory    file_path = os.path.join(temp_dir, "sample.txt")      with open(file_path, "w") as f:          f.write("Hello, Temporary World!")      # Read back the file    with open(file_path, "r") as f:          print(f.read())  # At this point, the directory and its contents are deleted automaticallyprint("Temporary directory cleaned up automatically.")

输出结果:

Temporary directory created at: /tmp/tmpabcd1234  Hello, Temporary World!  Temporary directory cleaned up automatically.

关键在于 with 语句块结束时,目录和文件会自动删除,不需要手动调用 os.remove() 或 shutil.rmtree()

手动控制临时目录的生命周期

有时候需要更精细的控制,比如临时目录的生命周期超出单个函数作用域,这时候可以用 tempfile.mkdtemp()

import tempfile  import shutil  import os  # Create a temporary directory manuallytemp_dir = tempfile.mkdtemp()  print(f"Created temporary directory: {temp_dir}")  # Work inside itfile_path = os.path.join(temp_dir, "example.txt")  with open(file_path, "w") as f:      f.write("Manual cleanup required!")  print("Files inside temp dir:", os.listdir(temp_dir))  # Clean up manually when doneshutil.rmtree(temp_dir)  print("Temporary directory removed.")

这种方式下需要自己负责清理工作,用完记得删除。

自定义临时目录的命名和位置

tempfile 支持给临时目录添加前缀和后缀,方便调试时识别:

import tempfile  # Create with custom prefix and suffixwith tempfile.TemporaryDirectory(prefix="myapp_", suffix="_data") as temp_dir:      print(f"Created: {temp_dir}")

输出类似这样:

Created: /tmp/myapp_abcd1234_data

还可以指定父目录:

with tempfile.TemporaryDirectory(dir="/path/to/parent") as temp_dir:      print(temp_dir)

当系统默认的临时目录权限不够或者空间不足时,这个功能就派上用场了。

实战案例:安全处理 ZIP 文件

下载大型 ZIP 文件后临时解压处理,处理完就清理掉:

import tempfile  import zipfile  def extract_and_process(zip_path):      with tempfile.TemporaryDirectory() as tmp_dir:          print(f"Extracting to {tmp_dir}")          with zipfile.ZipFile(zip_path, "r") as zip_ref:              zip_ref.extractall(tmp_dir)          # Process extracted files        for file in os.listdir(tmp_dir):              print("Processing:", file)

整个流程结束后,解压的文件夹自动删除,磁盘不会留下任何垃圾文件。

实战案例:动态生成报告

应用程序按需生成报告文件(PDF、CSV 之类),不需要永久存储:

import tempfile  import csv  import os  def generate_temp_report(data):      with tempfile.TemporaryDirectory() as tmp_dir:          file_path = os.path.join(tmp_dir, "report.csv")          with open(file_path, "w", newline="") as csvfile:              writer = csv.writer(csvfile)              writer.writerow(["Name", "Age"])              writer.writerows(data)          print(f"Report generated at: {file_path}")          # Here you can upload it, email it, or read the content directly

生成的报告可以直接上传、发邮件或者读取内容,不会在本地留存。

实战案例:单元测试中的文件操作

写单元测试时在项目目录下创建很多文件夹显然不是好主意,所以临时目录完美解决这个问题:

import tempfile  import unittest  import os  class TestFileOperations(unittest.TestCase):      def test_temp_directory(self):          with tempfile.TemporaryDirectory() as temp_dir:              file_path = os.path.join(temp_dir, "test.txt")              with open(file_path, "w") as f:                  f.write("test data")              self.assertTrue(os.path.exists(file_path))

每个测试用例都在独立的临时环境中运行,互不干扰,也不需要手动清理。

嵌套临时目录

复杂场景下可能需要嵌套的临时目录结构:

import tempfile  import os  with tempfile.TemporaryDirectory() as root_dir:      print(f"Root: {root_dir}")      sub_dir = tempfile.mkdtemp(dir=root_dir)      print(f"Nested: {sub_dir}")

多阶段数据处理流程中,每个阶段可以有自己的独立沙箱环境。

使用临时目录的几个注意事项

始终使用上下文管理器 with tempfile.TemporaryDirectory() 来确保自动清理。不要硬编码 /tmp 路径,用 tempfile.gettempdir() 获取系统临时目录。如果用了 mkdtemp() 就必须手动调用 shutil.rmtree() 清理。给临时目录加上有意义的前缀方便调试时快速定位。临时数据随时可能被系统清理,不要在里面存放需要持久化的信息。

几个实用技巧

获取系统临时目录路径:

importtempfileprint(tempfile.gettempdir())

生成唯一文件名(但不创建文件):

tempfile.mktemp()

不过要注意,直接用 mktemp() 有安全风险,生产环境建议用 NamedTemporaryFile 或 TemporaryDirectory

生产环境中的实际应用

下面这段代码展示了如何在 PDF 处理项目中使用临时目录。整个流程包括 PDF 转图片、图片转 Markdown、最后合并成完整文档:

import os  import io  import shutil  import tempfile  from pathlib import Path  from typing import Iterable, Optional, Callable, Tuple  # Requires: pip install pymupdf pillow  import fitz  # PyMuPDF  from PIL import Image  
def process_pdfs_to_markdown(      pdf_paths: Iterable[str | os.PathLike],      output_dir: str | os.PathLike,      *,      page_image_dpi: int = 200,      image_format: str = "PNG",      llm_page_markdown_fn: Optional[Callable[[Path], str]] = None,  ) -> Tuple[list[Path], list[Path]]:      """      Convert each input PDF into page images using a temporary workspace, run an LLM on each page image to get      Markdown, save one MD per page (still in a temp workspace), then merge the per-PDF Markdown into a single      non-temporary Markdown file per PDF in `output_dir`.      Non-temp file handling is kept simple (write final merged .md into `output_dir`), while the heavy lifting      uses temp directories that auto-clean on success or error.      Parameters      ----------      pdf_paths : Iterable[str | PathLike]          Paths to PDF files to process.      output_dir : str | PathLike          Directory where FINAL merged Markdown files (non-temp) will be written.      page_image_dpi : int, optional          Rendering resolution for converting PDF pages to images. Higher DPI → sharper (default 200).      image_format : str, optional          Image format for page renders (e.g., "PNG", "JPEG"). Default "PNG".      llm_page_markdown_fn : Callable[[Path], str], optional          A callable that takes a Path to a page image and returns Markdown text for that page.          If not provided, a placeholder stub will be used.      Returns      -------      Tuple[list[Path], list[Path]]          A tuple (final_markdown_files, per_page_markdown_files_flattened)          - final_markdown_files: list of merged Markdown file paths written in output_dir (non-temp)          - per_page_markdown_files_flattened: flattened list of all per-page MD files (in temp, ephemeral)            (Returned for inspection/logging; these will be deleted when temp dir goes away.)      Notes      -----      - Uses a single top-level TemporaryDirectory for the whole batch to keep structure neat.      - For each PDF, creates `/tmp/.../<pdf_stem>/images` and `/tmp/.../<pdf_stem>/md`.      - Each page is rendered to an image file named `page-<index>.<ext>`.      - Each page's Markdown is saved to `page-<index>.md`.      - Finally, merges all page MDs for that PDF into `<output_dir>/<pdf_stem>.md` (non-temp).      - Replace `llm_stub_markdown_from_image` with your actual LLM call (OpenAI, local VLM, etc.).      Pseudocode hint for real LLM integration      ----------------------------------------      def llm_page_markdown_fn(img_path: Path) -> str:          # pseudo:          # bytes = img_path.read_bytes()          # resp = my_llm_client.vision_to_md(image=bytes, system_prompt="Extract content as Markdown.")          # return resp.markdown          pass      """      output_dir = Path(output_dir)      output_dir.mkdir(parents=True, exist_ok=True)      # --- Local helper: default LLM stub (replace this with your LLM call) ---      def llm_stub_markdown_from_image(img_path: Path) -> str:          # This is a placeholder. Swap with a real LLM/VLM call to convert the image to Markdown.          # You can pass the image bytes and ask the model to produce clean Markdown with headings, tables, lists, etc.          return f"# Page extracted (stub)\n\n_Image: {img_path.name}_\n\n> Replace this with real LLM Markdown output."      # Choose the LLM function (user-supplied or stub)      llm_to_md = llm_page_markdown_fn or llm_stub_markdown_from_image      final_markdown_files: list[Path] = []      per_page_markdown_files_flattened: list[Path] = []      # Top-level temp root for the entire run      with tempfile.TemporaryDirectory(prefix="pdf2img-md_") as temp_root:          temp_root = Path(temp_root)          for pdf_path in map(Path, pdf_paths):              if not pdf_path.exists() or pdf_path.suffix.lower() != ".pdf":                  # Skip invalid entries gracefully; alternatively raise ValueError                  continue              pdf_stem = pdf_path.stem              pdf_temp_dir = temp_root / pdf_stem              images_dir = pdf_temp_dir / "images"              md_dir = pdf_temp_dir / "md"              images_dir.mkdir(parents=True, exist_ok=True)              md_dir.mkdir(parents=True, exist_ok=True)              # --- 1) Render pages to images in temp ---              # Using PyMuPDF: fast, no external poppler dependency              pages_rendered: list[Path] = []              with fitz.open(pdf_path) as doc:                  # scale based on DPI (PyMuPDF normally uses zoom factors; convert DPI to zoom)                  # Base DPI ~72; zoom = target_dpi / 72                  zoom = page_image_dpi / 72.0                  mat = fitz.Matrix(zoom, zoom)                  for page_index in range(doc.page_count):                      page = doc.load_page(page_index)                      pix = page.get_pixmap(matrix=mat, alpha=False)  # no alpha for standard formats                      img_bytes = pix.tobytes(output=image_format.lower())                      img_name = f"page-{page_index + 1}.{image_format.lower()}"                      img_path = images_dir / img_name                      # Save via PIL to ensure consistent headers/metadata if needed                      with Image.open(io.BytesIO(img_bytes)) as im:                          im.save(img_path, format=image_format)                      pages_rendered.append(img_path)              # --- 2) For each page image, call LLM to get Markdown; save per-page MD in temp ---              page_md_files: list[Path] = []              for img_path in pages_rendered:                  md_text = llm_to_md(img_path)  # <-- your real LLM call here                  md_path = md_dir / (img_path.stem + ".md")                  md_path.write_text(md_text, encoding="utf-8")                  page_md_files.append(md_path)                  per_page_markdown_files_flattened.append(md_path)              # --- 3) Merge per-page MD into a FINAL non-temp Markdown file (one per PDF) ---              final_md_path = output_dir / f"{pdf_stem}.md"              # If you want sophisticated merging rules, implement here (e.g., front matter, TOC).              # Pseudocode for richer post-processing could be:              #   combined = render_front_matter(pdf_path) + "\n" + concatenate_markdown(page_md_files) + "\n" + add_toc()              #   final_md_path.write_text(combined, encoding="utf-8")              with final_md_path.open("w", encoding="utf-8") as fout:                  fout.write(f"<!-- Source PDF: {pdf_path.name} -->\n")                  fout.write(f"# {pdf_stem}\n\n")                  for i, md_file in enumerate(sorted(page_md_files, key=lambda p: p.name), start=1):                      fout.write(f"\n\n---\n\n<!-- Page {i} -->\n\n")                      fout.write(md_file.read_text(encoding="utf-8"))              final_markdown_files.append(final_md_path)          # NOTE:          # All temp content (images & per-page MDs) is automatically cleaned up on exit.      return final_markdown_files, per_page_markdown_files_flattened

这段代码的亮点在于所有中间文件(图片、单页 Markdown)都存放在临时目录里,处理完自动清理,只保留最终合并后的文档。整个流程非常干净,不会在磁盘上留下任何垃圾文件。

实际使用时把 llm_stub_markdown_from_image 替换成真正的 LLM 调用(比如 OpenAI 的 Vision API 或者本地视觉模型),就能实现完整的 PDF 文档处理流程。

总结

临时目录在 Python 开发中确实是个实用的工具,文件处理更高效也更安全。不管是处理用户上传、写单元测试还是构建数据流水线,tempfile.TemporaryDirectory() 都能让代码更简洁、更可靠。掌握它的用法能省不少麻烦,代码质量也能上个台阶。

作者 Sravanth

长按或扫描下方二维码,免费获取 Python公开课和大佬打包整理的几百G的学习资料,内容包含但不限于Python电子书、教程、项目接单、源码等等

推荐阅读

Python 提速 20%,来看看 Python 3.15 中的新特性

Python向量搜索实战:让14万文档的检索速度提升54倍!

从零开始:用Python和Gemini 3四步搭建你自己的AI Agent

Pixeltable:一张表搞定embeddings、LLM、向量搜索,多模态开发不再拼凑工具

点击 阅读原文 了解更多

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-09 00:43:13 HTTP/2.0 GET : https://f.mffb.com.cn/a/460720.html
  2. 运行时间 : 0.099672s [ 吞吐率:10.03req/s ] 内存消耗:4,855.80kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=c2d7809f4f8b8aa7f7f3d6ef492afd6c
  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.000719s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000981s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001231s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000310s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000672s ]
  6. SELECT * FROM `set` [ RunTime:0.000247s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000804s ]
  8. SELECT * FROM `article` WHERE `id` = 460720 LIMIT 1 [ RunTime:0.003224s ]
  9. UPDATE `article` SET `lasttime` = 1770568993 WHERE `id` = 460720 [ RunTime:0.011127s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000309s ]
  11. SELECT * FROM `article` WHERE `id` < 460720 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000647s ]
  12. SELECT * FROM `article` WHERE `id` > 460720 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000769s ]
  13. SELECT * FROM `article` WHERE `id` < 460720 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001410s ]
  14. SELECT * FROM `article` WHERE `id` < 460720 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001781s ]
  15. SELECT * FROM `article` WHERE `id` < 460720 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002093s ]
0.101305s