当前位置:首页>python>第4.4章:速览Python的常用高级语法

第4.4章:速览Python的常用高级语法

  • 2026-08-19 13:46:47
第4.4章:速览Python的常用高级语法

《Python AI 应用开发入门》第 4.4 节。

使用解包与模式匹配处理结构化数据,理解装饰器和上下文管理器的基本运行机制。

本节目标

学完本节后,你应当能够:

  1. 1. 使用序列解包把数据分配给多个变量。
  2. 2. 使用 * 收集剩余元素。
  3. 3. 使用 ** 合并字典并向函数传递关键字参数。
  4. 4. 使用 match / case 处理结构化命令。
  5. 5. 解释 case 模式、通配分支和守卫条件。
  6. 6. 说明函数为什么可以作为值传递和返回。
  7. 7. 展开并解释 @decorator 语法。
  8. 8. 编写不会丢失参数、返回值和异常的简单装饰器。
  9. 9. 解释 with 进入和离开代码块时发生了什么。
  10. 10. 使用类或 contextlib.contextmanager 创建简单上下文管理器。

1. 序列解包

当一组数据的位置固定、含义明确时,可以按索引逐项取出:

command = ("add", "user", "你好")action = command[0]role = command[1]content = command[2]

不过,变量名和索引分开书写,不容易一眼看出三项数据的对应关系。序列解包可以在一次赋值中把各项交给对应变量:

action, role, content = commandprint(action)   # addprint(role)     # userprint(content)  # 你好

可以把它理解为:Python 把右侧序列拆开,再按照位置交给等号左侧的变量。因此两边数量必须一致:

# action, role = command# ValueError: too many values to unpack

列表、元组和字符串等可以逐项读取的对象都能参与解包:

first, second = ["user", "assistant"]letter_a, letter_b = "AI"

解包适合结构固定、每个位置含义明确的数据。如果长度不确定,直接固定多个变量接收就容易报错。

2. 使用 * 收集剩余元素

命令内容可能包含多个单词:

parts = ["add", "user", "请", "解释", "数据类"]action, role, *content_parts = partsprint(action)         # addprint(role)           # userprint(content_parts)  # ['请', '解释', '数据类']

action 和 role 分别接收前两项,带 * 的 content_parts 会把剩余所有元素收集成一个列表:

content = " ".join(content_parts)print(content)  # 请 解释 数据类

也可以收集开头或中间部分:

first, *middle, last = [1, 2, 3, 4, 5]print(first)   # 1print(middle)  # [2, 3, 4]print(last)    # 5

一次解包中只能有一个带 * 的变量,否则 Python 无法判断“剩余元素”应该交给谁。

3. 交换变量与忽略数据

解包可以交换变量:

current_role = "user"next_role = "assistant"current_role, next_role = next_role, current_role

如果某个位置的值不需要使用,通常用 _ 接收:

role, _, content = ("user", "message-001", "你好")

Python 并没有为 _ 赋予“删除这个值”的特殊能力,它仍然是普通变量名。这里的下划线只是告诉读者“这个位置的值后面不会用到”,因此不要再依赖 _ 保存重要数据。

4. 字典解包

项目配置常常由“默认配置”和“用户配置”两部分组成。** 可以把两个字典的键值对展开到一个新字典中:

default_config = {    "model": "demo-model",    "style": "简洁",    "max_history": 50,}user_config = {    "style": "详细",    "max_history": 20,}config = {    **default_config,    **user_config,}print(config)

Python 按书写顺序合并这些键值对。遇到同名键时,后面的值覆盖前面的值,所以这里的用户配置会覆盖默认配置中的 style 和 max_history

合并配置时,书写顺序就是覆盖规则,要先确认谁应该拥有更高优先级。密码、权限等安全设置也不应交给未经验证的输入任意覆盖。

5. 调用函数时解包

上一章在函数定义中见过 *args 和 **kwargs。在函数调用的位置,* 和 ** 做的是相反方向的工作:把已有容器拆开,再传给函数。

def create_message(role, content):    return {        "role": role,        "content": content,    }values = ("user", "解释解包")message = create_message(*values)

字典键可以对应参数名:

values = {    "role": "user",    "content": "解释字典解包",}message = create_message(**values)

create_message(*values) 会按顺序传入元组中的两项;create_message(**values) 会把字典键当作参数名、字典值当作参数值。

因此要区分两个位置:

  • • 定义函数时,*args 和 **kwargs 用来收集参数。
  • • 调用函数时,*values 和 **values 用来展开参数。

6. 用 match / case 选择处理方式

多个命令可以使用 if / elif

if action == "add":    print("添加消息")elif action == "list":    print("查看消息")elif action == "exit":    print("退出")

当判断的不只是一个值,还包括列表或字典的结构时,连续的 if / elif 会逐渐变得难读。Python 3.10 及以上提供了结构化模式匹配:

match action:    case "add":        print("添加消息")    case "list":        print("查看消息")    case "exit":        print("退出")    case _:        print("未知命令")

match 后面是要检查的数据,每个 case 描述一种可能的值或结构。Python 从上到下检查,执行第一个匹配的分支。case _ 不限制具体值,因此用作最后的默认分支。

match 不需要替代所有 if。判断年龄是否大于 18、字符串是否为空等真假条件,仍然更适合使用 ifmatch 更适合根据固定值或数据结构选择处理方式。

7. 匹配并提取序列数据

模式匹配不仅能判断命令类型,还能顺便把命令中的数据取出来:

def handle_command(command):    parts = command.split()    match parts:        case ["list"]:            return "查看全部消息"        case ["add", role, *content_parts] if content_parts:            content = " ".join(content_parts)            return f"添加 {role} 消息:{content}"        case ["recent", amount_text]:            return f"查看最近 {amount_text} 条"        case ["exit"]:            return "退出程序"        case _:            return "命令格式无效"

逐个看这些模式:

  • • ["list"] 只匹配一个元素且内容是 list 的序列。
  • • ["add", role, *content_parts] 匹配以 add 开头的序列,并提取角色与剩余内容。
  • • if content_parts 是守卫条件。序列结构匹配后,还要确认内容列表不是空的。
  • • 模式不匹配时继续检查下一个 case

模式中的 role 和 content_parts 是接收数据的新变量,不是要拿来比较的固定值,因此不需要提前定义。

8. 匹配字典结构

JSON 消息解析后会得到字典。字典模式可以检查必需的键是否存在,同时取出对应的值:

def describe_message(value):    match value:        case {"role": "user", "content": content}:            return f"用户:{content}"        case {"role": "assistant", "content": content}:            return f"助手:{content}"        case {"role": role, "content": content}:            return f"{role}{content}"        case _:            raise ValueError("消息结构无效")

例如第一条模式要求 role 的值必须是 "user",并把 content 对应的值交给同名变量。字典模式只要求写出来的键存在,原字典可以包含其他额外键。

模式匹配能确认键和值的大致结构,却不会自动检查 content 是不是为非空字符串。仍然需要进一步验证:

def describe_non_empty_message(value):    match value:        case {"role": role, "content": content} if isinstance(content, str) and content.strip():            return f"{role}{content.strip()}"        case _:            raise ValueError("消息内容无效")

9. 函数也可以作为值使用

理解装饰器前,先回顾一个关键点:定义函数后,函数名保存的是一个可以调用的函数对象。它也能像字符串、列表一样,被赋给变量、作为参数传入,或者从另一个函数返回。

函数可以赋给变量:

def greet(name):    return f"你好,{name}"formatter = greetprint(formatter("小林"))

可以作为参数传入:

def run_formatter(formatter, value):    return formatter(value)print(run_formatter(greet, "小林"))

formatter = greet 没有执行 greet,因为后面没有括号;它只是让 formatter 也指向这个函数。直到写出 formatter("小林") 时,函数才真正执行。

函数也可以从另一个函数返回。上一章学习闭包时已经使用过这种能力,装饰器正是在此基础上工作的。

10. 为什么需要装饰器

假设多个业务函数都要在调用前后记录日志。如果把记录代码直接写进每个函数,真正的业务步骤很快会被重复代码包围:

def save_history():    print("开始调用 save_history")    print("正在保存")    print("结束调用 save_history")

装饰器把这类重复步骤集中到一个地方:它接收原函数,创建一个负责附加行为的新函数,再把新函数返回。

最小装饰器:

def announce(function):    def wrapper(*args, **kwargs):        print(f"开始调用 {function.__name__}")        result = function(*args, **kwargs)        print(f"结束调用 {function.__name__}")        return result    return wrapper

手动使用:

def build_prompt(topic):    return f"请解释:{topic}"build_prompt = announce(build_prompt)print(build_prompt("装饰器"))

这段代码发生了三件事:

  1. 1. 原来的 build_prompt 被传给 announce()
  2. 2. announce() 返回内部定义的 wrapper
  3. 3. 变量 build_prompt 改为指向 wrapper,而 wrapper 仍然记得并会调用原函数。

因此再次调用 build_prompt("装饰器") 时,实际先进入 wrapper,打印开始信息,调用原函数,最后打印结束信息并返回原结果。

11. @ 装饰器语法

下面的写法:

@announcedef build_prompt(topic):    return f"请解释:{topic}"

等价于:

def build_prompt(topic):    return f"请解释:{topic}"build_prompt = announce(build_prompt)

@announce 写在函数定义上方,表示函数定义完成后,立即执行 build_prompt = announce(build_prompt)。它只是更简洁的语法,不是一套完全不同的运行机制。

装饰器常见用途包括:

  • • 记录函数调用。
  • • 测量执行时间。
  • • 检查权限。
  • • 缓存结果。
  • • 统一处理接口边界。

只有当某种附加行为会稳定地用于一批函数时,装饰器才有价值。如果额外步骤只服务于一个函数,或会隐藏重要的执行顺序,直接写清楚通常更容易维护。

12. 使用 functools.wraps

前面的装饰器还有一个小问题:装饰后变量指向的是 wrapper,所以函数名、文档字符串等信息也会变成包装器的信息:

print(build_prompt.__name__)  # wrapper

标准库 functools.wraps 会把原函数的重要信息复制到包装器上:

from functools import wrapsdef announce(function):    @wraps(function)    def wrapper(*args, **kwargs):        print(f"开始调用 {function.__name__}")        result = function(*args, **kwargs)        print(f"结束调用 {function.__name__}")        return result    return wrapper

因此,编写函数装饰器时通常要在包装器上加上 @wraps(function)

一个不改变原函数基本用法的包装器还应该:

  • • 把位置和关键字参数继续传给原函数。
  • • 返回原函数的结果。
  • • 不随意吞掉原函数异常。

13. with 为什么能自动清理资源

前一章使用:

with path.open("r", encoding="utf-8") as file:    content = file.read()

文件使用完后必须关闭。即使 file.read() 报错,with 也会负责执行关闭操作。能够配合 with 完成这类准备与清理工作的对象,叫作上下文管理器。

上下文管理器负责两个阶段:

  1. 1. 进入代码块前准备资源。
  2. 2. 离开代码块时清理资源,即使代码块中途发生异常。

一个类可以通过两个特殊方法支持 with

  • • __enter__():进入时调用,它的返回值交给 as 后的变量。
  • • __exit__():退出时调用,接收异常信息并执行清理。

14. 类形式的上下文管理器

文件对象已经实现了上下文管理器。下面再自己写一个简单的操作记录器,观察 with 的执行过程:

class OperationTrace:    def __init__(self, operation_name):        self.operation_name = operation_name    def __enter__(self):        print(f"开始:{self.operation_name}")        return self    def __exit__(self, error_type, error, traceback):        if error is None:            print(f"完成:{self.operation_name}")        else:            print(f"失败:{self.operation_name},原因:{error}")        return False

使用:

with OperationTrace("保存聊天历史") as trace:    print(trace.operation_name)    print("正在保存……")

正常执行顺序:

  1. 1. 创建 OperationTrace 对象。
  2. 2. 调用 __enter__()
  3. 3. 执行 with 内部代码。
  4. 4. 调用 __exit__()

如果代码块发生异常,Python 会把异常类型、异常对象和追踪信息传给 __exit__(),所以它仍有机会完成清理和记录。这里返回 False,表示错误没有被解决,应该继续向外传播。只有上下文管理器确实已经处理并恢复了错误时,才应考虑返回 True

15. 函数形式的上下文管理器

如果上下文管理器只需要简单的“准备—执行—清理”流程,可以使用标准库的 contextlib.contextmanager,不必专门定义一个类:

from contextlib import contextmanager@contextmanagerdef operation_trace(operation_name):    print(f"开始:{operation_name}")    try:        yield    except Exception as error:        print(f"失败:{operation_name},原因:{error}")        raise    else:        print(f"完成:{operation_name}")

使用:

with operation_trace("生成回答"):    print("正在生成……")

装饰器会把这个生成器函数转换成可供 with 使用的上下文管理器。可以把 yield 看成代码块的分界线:

  • • yield 前:进入上下文时执行。
  • • 执行到 yield:暂时停下,转去运行 with 代码块。
  • • 代码块结束后:回到 yield 后面继续执行。

如果需要保存较多状态、返回专门对象或提供额外方法,类形式更清楚;只有少量进入和退出步骤时,函数形式通常更简洁。

16. 装饰器和上下文管理器的区别

装饰器和上下文管理器都能在业务代码周围加入通用行为,但它们包围的范围不同:

工具
主要作用范围
典型用途
装饰器
某个函数的每次调用
调用日志、权限、缓存
上下文管理器
明确的代码块
文件、锁、临时状态、操作追踪

如果只想管理某几行代码,with 的范围一眼可见;如果一个函数每次被调用时都必须执行同样的附加行为,装饰器更合适。

17. 综合示例:处理命令

from contextlib import contextmanager@contextmanagerdef operation_trace(name):    print(f"开始:{name}")    try:        yield    finally:        print(f"结束:{name}")def parse_command(command):    parts = command.split()    match parts:        case ["add", role, *content_parts] if content_parts:            return "add", {                "role": role,                "content": " ".join(content_parts),            }        case ["recent", amount_text]:            return "recent", {"amount_text": amount_text}        case ["exit"]:            return "exit", {}        case _:            raise ValueError("命令格式无效")with operation_trace("解析命令"):    action, arguments = parse_command("add user 解释上下文管理器")print(action)print(arguments)

这个例子没有为了使用新语法而改变业务含义:

  • • match 提取命令结构。
  • • 序列解包接收函数返回值。
  • • 上下文管理器清楚标出需要追踪的操作范围。

所谓“高级语法”并不是越多越好。只有当一种写法能减少重复、让数据结构或执行范围更清楚时,才值得使用。

常见错误

解包数量不匹配

固定解包前先确认数据结构;长度变化时使用 *rest 或显式检查。

match 分支顺序错误

宽泛模式放在前面会让后面更具体的模式永远没有机会匹配。通配分支通常放最后。

装饰器忘记返回结果

包装器不返回原函数结果,会让调用者得到 None

装饰器吞掉异常

记录错误后通常应使用 raise 继续传播,除非装饰器明确负责恢复。

上下文管理器隐藏异常

__exit__() 返回真值会表示异常已处理。不能恢复时返回 False

动手练习

练习 1:命令解包与匹配

编写 parse_command(command),支持:

  • • add <role> <content...>
  • • recent <amount>
  • • list
  • • exit

返回动作名和参数字典,非法结构抛出 ValueError

练习 2:调用记录装饰器

编写 log_call

  • • 调用前打印函数名。
  • • 原样传递参数。
  • • 返回原函数结果。
  • • 使用 @wraps
  • • 原函数异常继续传播。

练习 3:操作上下文

分别使用类和 @contextmanager 实现操作追踪,测试正常结束和主动抛出异常两种情况,确认清理信息都会输出。

随堂小测

  1. 1. first, *middle, last 中 middle 是什么类型?
  2. 2. 字典解包出现同名键时使用哪个值?
  3. 3. case _ 的作用是什么?
  4. 4. 守卫条件在什么时候检查?
  5. 5. @announce 与哪段普通赋值代码等价?
  6. 6. 为什么装饰器包装器要返回原函数结果?
  7. 7. @wraps 解决什么问题?
  8. 8. __enter__ 的返回值会交给哪里?
  9. 9. __exit__ 返回 False 表示什么?
  10. 10. 装饰器和上下文管理器的作用范围有什么区别?

参考答案

  1. 1. 列表。
  2. 2. 后展开或后写入的值。
  3. 3. 匹配前面分支没有处理的任何值,通常作为默认分支。
  4. 4. 结构模式匹配成功后、执行分支代码前。
  5. 5. function = announce(function)
  6. 6. 否则包装后函数会丢失原结果,调用者得到 None
  7. 7. 保留原函数名称、文档等元数据。
  8. 8. as 后面的变量。
  9. 9. 上下文管理器没有吞掉异常,异常应继续传播。
  10. 10. 装饰器通常覆盖某个函数的每次调用;上下文管理器覆盖明确的代码块。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 16:50:13 HTTP/2.0 GET : https://f.mffb.com.cn/a/511230.html
  2. 运行时间 : 0.321311s [ 吞吐率:3.11req/s ] 内存消耗:4,883.87kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=2f6c4022498fc31301591550ef39ed44
  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.000992s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001407s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.007976s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.002759s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001390s ]
  6. SELECT * FROM `set` [ RunTime:0.000604s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001539s ]
  8. SELECT * FROM `article` WHERE `id` = 511230 LIMIT 1 [ RunTime:0.001327s ]
  9. UPDATE `article` SET `lasttime` = 1787302213 WHERE `id` = 511230 [ RunTime:0.030475s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.007460s ]
  11. SELECT * FROM `article` WHERE `id` < 511230 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001514s ]
  12. SELECT * FROM `article` WHERE `id` > 511230 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.032674s ]
  13. SELECT * FROM `article` WHERE `id` < 511230 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.045327s ]
  14. SELECT * FROM `article` WHERE `id` < 511230 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.006134s ]
  15. SELECT * FROM `article` WHERE `id` < 511230 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.021280s ]
0.324931s