当前位置:首页>python>python 08: Typer 命令行程序的“接口层”重新理顺

python 08: Typer 命令行程序的“接口层”重新理顺

  • 2026-04-12 14:56:29
python 08: Typer 命令行程序的“接口层”重新理顺

系列文章:Python 奇技淫巧 #008
很多 Python 脚本一开始只是“顺手加个参数”,结果很快就会演变成:帮助信息没人维护、布尔开关越来越多、子命令挤在一个文件里、argparse 配置比业务逻辑还长。如果你最近在写自动化脚本、内部工具、数据任务、AI 流水线,Typer 很值得补上。它把命令行程序重新拉回到“函数签名驱动”的写法:你写的是 Python 类型,用户得到的却是更专业的 CLI 体验。


📌 为什么这篇值得写?

很多 Python 开发者第一次做 CLI,都走过同一条路:

  1. 1. 先写一个脚本
  2. 2. 加两个命令行参数
  3. 3. 再补一个布尔开关
  4. 4. 再拆两个子命令
  5. 5. 最后发现“参数解析代码”已经快和业务逻辑一样多了

问题不在于 argparse 不够强,而在于它很容易让命令行程序的“接口定义”散落在大量样板代码里。

现代 Python CLI 真正常见的痛点,其实是这几件事:

  • • ❌ 参数一多,帮助信息和默认值越来越难维护
  • • ❌ 布尔开关、枚举值、路径校验全靠手工补
  • • ❌ 子命令一上来,代码结构很快从脚本变成参数迷宫
  • • ❌ 想让 CLI 更像“工具”,而不是“脚本入口”,却发现维护成本明显上升
  • • ❌ 输出层、业务层、参数层缠在一起,测试和重构都不舒服

Typer 最值钱的地方,不是少写几行参数代码,而是把 CLI 的接口契约重新写回 Python 函数签名里。

一句话判断:

如果 Rich 是把命令行程序的“表现层”补齐,那么 Typer 就是在把命令行程序的“接口层”重新理顺。


🖼️ 先看图:Typer 到底解决了什么?

上面这张图是我自制的 SVG 信息图。SVG 本质上是用代码描述的矢量图,放大不糊、修改方便、特别适合技术文章里的流程图、结构图和对比图,所以很适合拿来做这种“核心价值总览”类配图。


🎯 Typer 是什么?

Typer 是一个用来构建 Python 命令行程序的库,由 FastAPI 作者 Sebastián Ramírez 开发,底层建立在 Click 之上,但把 Python 类型提示 放到了更核心的位置。

你可以把它理解成:

Typer = 用接近写普通函数的方式,做出更专业、更可维护的 CLI。

它最核心的思路很简单:

  • • 你定义函数参数
  • • 你给参数写类型
  • • 你决定哪些参数有默认值
  • • Typer 根据这些信息自动推导命令行参数、选项、帮助信息与校验行为

这意味着,CLI 的“定义来源”会更接近业务本身,而不是散落在手工拼接的解析逻辑里。

下面这张表最能说明 Typer 的价值:

所以我对 Typer 的判断是:

它真正厉害的不是“把 Click 再包装一下”,而是把 Python 的类型提示变成了命令行接口设计的一部分。


🆚 和 argparse、Click 到底差在哪?

先说结论:

  • • 如果你只是写一个一次性的小脚本argparse 仍然够用
  • • 如果你已经有大量 Click 代码,继续沿用 Click 也完全合理
  • • 如果你想用更现代、更低样板代码的方式组织 Python CLI,Typer 会非常顺手

下面这张对比表更直观:

Typer 和 Click 的关系,最容易这样理解:

Click 更像一套成熟的 CLI 基建;Typer 则是在这套基建上,把“类型提示驱动”的开发体验往前推了一步。

如果你已经习惯 FastAPI 的那种写法,Typer 通常会让你有一种很熟悉的感觉:

  • • 函数签名更重要
  • • 类型不是注释,而是接口的一部分
  • • 帮助信息不是善后,而是定义过程里的组成部分

🚀 3 分钟上手:先把一个普通函数变成 CLI

安装

pip install typer

最小示例

import typer


def
 main(name: str, repeat: int = 1, uppercase: bool = False):
    for
 _ in range(repeat):
        message = f"Hello, {name}"
        typer.echo(message.upper() if uppercase else message)


if
 __name__ == "__main__":
    typer.run(main)

这段代码里最值得注意的是两件事:

  1. 1. name: str 没有默认值,所以它会被当成 必填参数
  2. 2. repeat: int = 1 和 uppercase: bool = False 有默认值,所以它们会被当成 选项

也就是说,你写的不是“参数解析配置”,而是一个普通的 Python 函数;但 Typer 会把它解释成 CLI 接口。

你大致会得到这样的使用方式:

python hello.py xiaofeng --repeat 2 --uppercase
python hello.py --help

这种写法最让人舒服的地方在于:

  • • 学习成本很低
  • • 代码几乎没有样板负担
  • • 参数定义和业务逻辑之间的距离很近

这也是 Typer 最容易让人上头的地方:

它不是让你学一套新的“命令行 DSL”,而是尽量让你继续写正常的 Python。


1️⃣ 第一个重点:函数签名就是 CLI 契约

Typer 最值得学的,不只是 typer.run(main) 这一层,而是它能把很多命令行接口规则直接写进类型和注解里。

下面是一个更接近真实项目的例子:

from enum import Enum
from
 pathlib import Path
from
 typing import Annotated

import
 typer


class
 ExportFormat(str, Enum):
    html = "html"
    markdown = "markdown"
    text = "text"


app = typer.Typer()


@app.command()

def
 export(
    source: Annotated[
        Path,
        typer.Argument(exists=True, dir_okay=False, help="源 Markdown 文件路径"),
    ],
    target: Annotated[
        Path | None,
        typer.Option("--target", "-o", help="导出文件路径,不传则自动推导"),
    ] = None,
    format
: Annotated[
        ExportFormat,
        typer.Option("--format", help="导出格式"),
    ] = ExportFormat.html,
    overwrite: Annotated[
        bool
,
        typer.Option("--overwrite/--no-overwrite", help="是否覆盖已有文件"),
    ] = False,
):
    typer.echo(f"source={source}")
    typer.echo(f"target={target}")
    typer.echo(f"format={format}")
    typer.echo(f"overwrite={overwrite}")


if
 __name__ == "__main__":
    app()

这段代码的价值,不只是“它能跑”,而是它把很多规则写得非常集中:

  • • Path 表达这是一个路径
  • • exists=True 表达源文件必须存在
  • • ExportFormat 表达参数只能取若干固定值
  • • --overwrite/--no-overwrite 明确了一个布尔开关的两种形态
  • • help=... 直接把帮助信息贴在接口定义旁边

这种体验为什么重要?

因为你在维护 CLI 时,最怕的不是功能多,而是:

接口约束散了。

Typer 的好处就是把这些约束尽量收拢到函数参数这一层,让代码更像一份清晰的接口声明,而不是东一块、西一块的参数处理逻辑。


2️⃣ 第二个重点:当脚本长大以后,Typer 更容易长成“工具”

很多人对命令行程序的误解是:

“CLI 不就是一个带参数的脚本吗?”

真到项目里,你很快就会发现不是。

一个长期维护的 CLI,往往会越来越像下面这种结构:

  • • new:创建资源
  • • build:执行构建
  • • check:做校验
  • • sync:同步远端状态
  • • preview:本地预览

这时,最重要的已经不是“怎么解析参数”,而是:

怎么把命令组织成一个稳定、好找、可扩展的工具。

Typer 在这方面很顺,因为你可以很自然地把命令拆开,再按领域挂到总入口上:

import typer

app = typer.Typer(help="内容工作流 CLI")
article_app = typer.Typer(help="文章相关命令")
assets_app = typer.Typer(help="静态资源相关命令")

app.add_typer(article_app, name="article")
app.add_typer(assets_app, name="assets")


@article_app.command("new")

def
 article_new(title: str):
    typer.echo(f"创建文章:{title}")


@article_app.command("build")

def
 article_build(slug: str):
    typer.echo(f"构建文章:{slug}")


@assets_app.command("optimize")

def
 assets_optimize(path: str):
    typer.echo(f"优化资源:{path}")


if
 __name__ == "__main__":
    app()

这样之后,你的命令行体验就会更像一个真正的工具:

tool article new
tool article build
tool assets optimize

这点非常关键。

因为当脚本开始演化成团队工具、自动化入口、数据管道控制台时,真正决定可维护性的,往往不是参数解析细节,而是:

  • • 命令分层是不是清楚
  • • 子命令能不能自然扩展
  • • 帮助信息是不是一眼就能扫懂
  • • 新同事进来后能不能快速知道“应该用哪个命令”

Typer 很适合做这种“从脚本升级到工具”的过渡。


3️⃣ 第三个重点:CLI 外壳应该薄,业务逻辑应该还是普通 Python

这是我非常在意的一点。

很多 CLI 写着写着会变得很难测,原因不是命令行本身,而是开发者把所有逻辑都堆进了命令函数里。

更好的思路是:

  • • Typer 负责命令入口
  • • 普通函数负责业务逻辑
  • • CLI 只做参数接收、调用、输出与异常收束

例如:

from pathlib import Path
import
 typer

app = typer.Typer()


def
 build_article(markdown_path: Path, theme: str) -> Path:
    output_path = markdown_path.with_suffix(".html")
    html = f"<html><body><h1>{markdown_path.stem}</h1><p>theme={theme}</p></body></html>"
    output_path.write_text(html, encoding="utf-8")
    return
 output_path


@app.command()

def
 build(path: Path, theme: str = "default"):
    result = build_article(path, theme)
    typer.echo(f"已生成:{result}")


if
 __name__ == "__main__":
    app()

这个结构看起来简单,但工程价值很高:

  • • build_article() 可以单独测试
  • • 以后改成 Web 接口、任务队列、GUI 按钮也能复用这层逻辑
  • • 命令行只是入口,不会绑死你的业务能力

所以我很推荐把 Typer 理解成:

CLI 的壳层框架,而不是业务逻辑容器。

一旦你这么分层,代码的寿命会明显变长。


🧩 一个真实应用例子:做一个“系列文章工作流 CLI”

下面这个例子和我最近写这组 Python 系列文章的工作方式很接近:

  • • 新建一篇文章骨架
  • • 统计现有文章结构数据
  • • 检查某篇文章的配图数量是否达标

它不是玩具 demo,而是很接近你在内容生产、数据任务或内部工具里会真的写出来的命令行工具。

from __future__ import annotations

from
 pathlib import Path
from
 typing import Annotated
import
 re

import
 typer


app = typer.Typer(help="管理 Python 技术系列文章的 CLI")
DOCS_DIR = Path("docs")
IMAGES_DIR = DOCS_DIR / "images"


def
 code_block_count(text: str) -> int:
    return
 text.count("```") // 2


@app.command()

def
 new(
    number: Annotated[int, typer.Argument(help="文章编号,例如 8")],
    slug: Annotated[str, typer.Argument(help="文章 slug,例如 typer")],
    title: Annotated[str, typer.Option("--title", "-t", prompt=True, help="文章标题")],
    summary: Annotated[str, typer.Option("--summary", prompt=True, help="一句话摘要")],
):
    DOCS_DIR.mkdir(exist_ok=True)
    IMAGES_DIR.mkdir(exist_ok=True)

    md_path = DOCS_DIR / f"python_tips_{number:03d}_{slug}.md"
    hero_path = IMAGES_DIR / f"{slug}_hero.svg"

    if
 md_path.exists():
        raise
 typer.BadParameter(f"{md_path.name} 已存在")

    template = f"""# {title}

> **系列文章:Python 奇技淫巧 #{number:03d}**  
> {summary}

---

## 📌 为什么这篇值得写?
"""


    md_path.write_text(template, encoding="utf-8")
    hero_path.write_text(
        '<svg width="1200" height="720" xmlns="http://www.w3.org/2000/svg"></svg>'
,
        encoding="utf-8",
    )

    typer.secho(f"已创建 Markdown:{md_path}", fg=typer.colors.GREEN)
    typer.echo(f"配图占位:{hero_path}")


@app.command()

def
 stats(
    pattern: Annotated[str, typer.Option("--pattern", "-p", help="匹配模式")] = "python_tips_*.md",
):
    for
 path in sorted(DOCS_DIR.glob(pattern)):
        text = path.read_text(encoding="utf-8")
        lines = len(text.splitlines())
        headings = len(re.findall(r"^## ", text, flags=re.MULTILINE))
        code_blocks = code_block_count(text)
        images = text.count("![")

        typer.echo(
            f"{path.name}\t行数={lines}\t二级标题={headings}\t代码块={code_blocks}\t配图={images}"

        )


@app.command()

def
 check(
    path: Annotated[Path, typer.Argument(exists=True, dir_okay=False, help="要检查的 Markdown 文件")],
    min_images: Annotated[int, typer.Option(help="最低配图数")] = 3,
):
    text = path.read_text(encoding="utf-8")
    images = text.count("![")

    if
 images < min_images:
        typer.secho(
            f"{path.name} 未通过:图片数={images},低于要求 {min_images}"
,
            fg=typer.colors.RED,
        )
        raise
 typer.Exit(code=1)

    typer.secho(f"{path.name} 通过检查:图片数={images}", fg=typer.colors.GREEN)


if
 __name__ == "__main__":
    app()

这个例子里,我最想强调的是 4 个点:

  1. 1. 命令职责很清楚newstatscheck 各管一件事
  2. 2. 参数自解释程度很高:从函数签名就能大致看懂 CLI 用法
  3. 3. 错误处理更像“用户提示”而不是 Python 崩栈BadParameterExit(code=1) 让 CLI 更像产品
  4. 4. 以后接 Rich 非常自然:Typer 负责命令结构,Rich 负责表格、面板、进度条和更漂亮的输出

这也是我为什么非常推荐把 Typer 和 Rich 连起来学:

  • • Typer 解决“这个工具怎么组织”
  • • Rich 解决“这个工具怎么展示”

两者放在一起,Python CLI 的完成度会明显提高。


🏭 生产实践经验 / 坑点 / 注意事项

1. 小工具别一上来就堆成“大一统命令”

如果你的 CLI 已经开始出现 10 个以上的选项,先别急着继续往一个命令上加。

先想一件事:

这是不是已经不是一个命令,而是多个子命令的集合?

很多 CLI 之所以越来越难用,不是因为库不行,而是结构没有及时拆开。

2. CLI 层尽量只做“接参数 + 调逻辑 + 打结果”

不要把全部业务逻辑直接塞进 @app.command() 的函数里。

原因很现实:

  • • 测试难写
  • • 复用困难
  • • 迁移到 API、队列、Web 页面时很痛苦

把业务逻辑拆成普通函数,再让 Typer 负责入口,会舒服很多。

3. 复杂约束要尽量显式写在参数定义里

比如:

  • • 路径必须存在
  • • 文件不能是目录
  • • 选项只能取固定枚举值
  • • 是否覆盖要用显式布尔开关

这些约束越靠近参数定义,CLI 就越稳定,也越不容易在后续维护时走样。

4. 长期维护的工具,建议做成可安装命令

如果一个工具你会反复用、团队里也有人会用,就别总停留在:

python tool.py ...

更推荐配一个入口脚本,例如在 pyproject.toml 里这样写:

[project.scripts]
series
 = "series_cli:app"

这样安装后,你就能直接使用:

series new 8 typer --title "别再手搓 argparse 了"

这一步的意义,不只是省几次 python xxx.py,而是让这个工具更像稳定产品,而不是临时脚本。

5. Typer 很适合大多数现代 CLI,但不是所有 CLI

下面这些情况里,Typer 不一定是唯一答案:

  • • 你只是写一个极小的一次性脚本
  • • 你已经有成熟的 Click 代码库,迁移收益不一定立刻体现
  • • 你需要非常特殊的参数解析行为,直接用 Click 或底层库可能更稳

所以不要把它理解成“唯一正确答案”。

更准确的判断是:

当你希望 Python CLI 更现代、更清晰、更接近类型驱动开发时,Typer 往往是非常好的默认选项。


✅ 最适合什么场景?

我觉得 Typer 特别适合下面这些场景:

反过来说,如果只是 20 行脚本、只收 1-2 个参数、几乎不需要帮助信息,也不用为了“现代”而硬上框架。

但只要你已经开始感觉:

  • • “这个脚本以后可能还会继续长”
  • • “这个工具可能还会给别人用”
  • • “我不想把参数解析写成一团胶水”

那 Typer 就很值得提前上。


🧠 本文重点回顾

最后把这篇的核心结论收一下:

  1. 1. Typer 的核心价值不是省几行代码,而是让 CLI 接口定义回到函数签名里
  2. 2. 它建立在 Click 之上,但把类型提示放到了更中心的位置
  3. 3. 对现代 Python 开发者来说,它的写法通常比 argparse 更自然,也比手工组织 Click 更省力
  4. 4. 当脚本要长成团队工具时,Typer 很适合承担“命令结构层”
  5. 5. 和 Rich 搭配时,Typer 管结构,Rich 管表现,Python CLI 的完成度会明显上一个台阶

如果你最近正准备把某个脚本做成真正可复用的命令行工具,我的建议很直接:

先别急着继续堆 argparse 了,拿 Typer 写一个小工具试试。你很可能会发现,CLI 终于开始像你真正想维护的代码。


📚 延伸阅读

  • • Typer 官方文档:https://typer.tiangolo.com/
  • • Typer GitHub 仓库:https://github.com/fastapi/typer
  • • Click 官方文档:https://click.palletsprojects.com/
  • • Rich 官方文档:https://rich.readthedocs.io/

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-04-15 22:41:05 HTTP/2.0 GET : https://f.mffb.com.cn/a/486012.html
  2. 运行时间 : 0.284438s [ 吞吐率:3.52req/s ] 内存消耗:5,105.40kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=0644edfa0ba6f823daaa2449c7fecd55
  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.001034s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001388s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000623s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.002240s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001481s ]
  6. SELECT * FROM `set` [ RunTime:0.003089s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001483s ]
  8. SELECT * FROM `article` WHERE `id` = 486012 LIMIT 1 [ RunTime:0.044570s ]
  9. UPDATE `article` SET `lasttime` = 1776264066 WHERE `id` = 486012 [ RunTime:0.014301s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.007789s ]
  11. SELECT * FROM `article` WHERE `id` < 486012 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001960s ]
  12. SELECT * FROM `article` WHERE `id` > 486012 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001011s ]
  13. SELECT * FROM `article` WHERE `id` < 486012 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.032665s ]
  14. SELECT * FROM `article` WHERE `id` < 486012 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002804s ]
  15. SELECT * FROM `article` WHERE `id` < 486012 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002411s ]
0.288229s