当前位置:首页>python>Python 零基础100天—Day14 函数进阶

Python 零基础100天—Day14 函数进阶

  • 2026-07-02 16:46:05
Python 零基础100天—Day14 函数进阶

🐍 函数进阶 — 从会写到写好

🕐 预计用时:2-3 小时 | 🎯 目标:掌握 *args/**kwargs、作用域、lambda 和闭包基础


📖 今日目录

  1. *args:接收任意数量的位置参数
  2. **kwargs:接收任意数量的关键字参数
  3. 参数组合的完整规则
  4. 变量作用域(LEGB 规则)
  5. global 和 nonlocal
  6. lambda 匿名函数
  7. 闭包(Closure)入门
  8. 实战练习
  9. 今日小结

1. *args:接收任意数量的位置参数

有时候你不知道调用者会传几个参数——用 *args 来"打包"接收。

# 普通函数:参数数量固定
def add(a, b):
    return a + b

print(add(1, 2))       # 3
# print(add(1, 2, 3))  # ❌ TypeError

# *args:参数数量不固定
def add_all(*args):
    print(f"args = {args}")
    print(f"type = {type(args)}")  # tuple!
    return sum(args)

print(add_all(1, 2))          # args = (1, 2) → 3
print(add_all(1, 2, 3))       # args = (1, 2, 3) → 6
print(add_all(1, 2, 3, 4, 5)) # args = (1, 2, 3, 4, 5) → 15

💡 *args 本质上是一个元组!
Python 把多余的位置参数打包成元组,赋值给 args 这个变量名。
变量名不一定要叫 args*numbers*items 都行,* 才是关键。

📦 常见用法

# 日志函数:接收任意消息
def log(*messages):
    for msg in messages:
        print(f"[LOG] {msg}")

log("服务器启动", "端口8080", "等待连接")
# [LOG] 服务器启动
# [LOG] 端口8080
# [LOG] 等待连接

# 求平均值
def average(*numbers):
    return sum(numbers) / len(numbers)

print(average(80, 90, 85))    # 85.0
print(average(100, 95, 88, 92, 78))  # 90.6

# 打印函数
def print_info(name, *hobbies):
    print(f"{name} 的爱好:")
    for h in hobbies:
        print(f"  - {h}")

print_info("张三", "编程", "游泳", "看书")
# 张三 的爱好:
#   - 编程
#   - 游泳
#   - 看书

🔓 解包:把列表/元组展开为参数

def add(a, b, c):
    return a + b + c

nums = [1, 2, 3]
print(add(*nums))  # 6(等价于 add(1, 2, 3))

# * 解包列表/元组为位置参数
def show(*args):
    print(args)

show(*[1, 2, 3])    # (1, 2, 3)
show(*(4, 5, 6))    # (4, 5, 6)
show(*"hello")      # ('h', 'e', 'l', 'l', 'o')

2. **kwargs:接收任意数量的关键字参数

**kwargs 接收"多余的关键字参数",打包成字典。

def print_profile(**kwargs):
    print(f"kwargs = {kwargs}")
    print(f"type = {type(kwargs)}")  # dict!
    for key, value in kwargs.items():
        print(f"  {key}: {value}")

print_profile(name="张三", age=25, city="北京")
# kwargs = {'name': '张三', 'age': 25, 'city': '北京'}
#   name: 张三
#   age: 25
#   city: 北京

📦 常见用法

# 配置函数:接收任意配置项
def create_server(**config):
    host = config.get("host", "127.0.0.1")
    port = config.get("port", 8080)
    debug = config.get("debug", False)
    print(f"启动服务器: {host}:{port} (debug={debug})")

create_server()                          # 默认配置
create_server(port=3000, debug=True)     # 自定义配置

# 合并字典
def merge(*dicts):
    result = {}
    for d in dicts:
        result.update(d)
    return result

defaults = {"color": "red", "size": "medium"}
custom = {"size": "large", "weight": "bold"}
print(merge(defaults, custom))
# {'color': 'red', 'size': 'large', 'weight': 'bold'}

🔓 解包:把字典展开为关键字参数

def greet(name, age, city):
    print(f"{name}, {age}岁, {city}")

info = {"name": "张三", "age": 25, "city": "北京"}
greet(**info)  # 等价于 greet(name="张三", age=25, city="北京")

# ** 解包字典为关键字参数
def show(**kwargs):
    print(kwargs)

show(**{"a": 1, "b": 2})  # {'a': 1, 'b': 2}
show(**dict(x=10, y=20))  # {'x': 10, 'y': 20}

3. 参数组合的完整规则

Python 参数有严格的顺序,记住这个公式:

def func(pos_only, /, normal, *args, kw_only, **kwargs):
    pass
#         ↑         ↑      ↑       ↑         ↑
#     位置专属    普通参数  可变位置  关键字专属  可变关键字

📋 参数类型速查表

参数类型
语法
传入方式
位置专属
a, b, /
只能按位置
普通参数
a, b
位置或关键字
*args
*args
多余的位置参数打包
关键字专属
*, a, b
只能按关键字
**kwargs
**kwargs
多余的关键字参数打包
# 完整示例
def full_example(a, b, /, c, *args, d, e=100, **kwargs):
    print(f"a={a}, b={b}, c={c}")
    print(f"args={args}")
    print(f"d={d}, e={e}")
    print(f"kwargs={kwargs}")

full_example(1, 2, 3, 4, 5, d=6, e=7, x=8, y=9)
# a=1, b=2, c=3
# args=(4, 5)
# d=6, e=7
# kwargs={'x': 8, 'y': 9}

💡 日常开发中最常用的组合:
1. def f(a, b, *args) — 固定参数 + 可变位置参数
2. def f(a, b, **kwargs) — 固定参数 + 可变关键字参数
3. def f(*args, **kwargs) — 万能签名(接收一切)


4. 变量作用域(LEGB 规则)

Python 找变量的顺序:L → E → G → B,就像找钥匙一样——先翻自己的口袋,再找邻居的。

层级
名称
说明
L
Local
函数内部定义的变量
E
Enclosing
外层函数(闭包场景)
G
Global
模块顶层定义的变量
B
Built-in
Python 内置的(len, print, range...)
x = "全局变量"           # G: Global

def outer():
    x = "外层变量"       # E: Enclosing

    def inner():
        x = "内部变量"   # L: Local
        print(x)

    inner()              # 内部变量

outer()
print(x)                 # 全局变量(不受函数影响)

🔍 LEGB 查找过程

# L → E → G → B 的查找
name = "全局张三"

def test():
    # name = "局部张三"    # 如果取消注释,优先用局部的
    print(name)             # 找到全局的 → 全局张三

test()

# 内置函数的 B 层
# len 就是 B 层的变量
print(len([1, 2, 3]))      # 3(找到内置的 len 函数)

⚠️ 作用域陷阱:

x = 10

def test():
    print(x)    # ❌ UnboundLocalError!
    x = 20

# 原因:函数内有 x = 20 的赋值,Python 认为 x 是局部变量
# 但 print(x) 在赋值之前,所以报错

解决方法:用 global 声明,或者不要在函数内同名赋值。


5. global 和 nonlocal

🌐 global:在函数内修改全局变量

counter = 0               # 全局变量

def increment():
    global counter         # 声明:我要用全局的 counter
    counter += 1
    print(f"计数器: {counter}")

increment()   # 计数器: 1
increment()   # 计数器: 2
increment()   # 计数器: 3
print(counter) # 3(全局变量被修改了)
# 不用 global 的情况
name = "张三"

def change_name():
    name = "李四"       # 这是创建了一个局部变量,不是修改全局的
    print(f"函数内: {name}")

change_name()           # 函数内: 李四
print(f"函数外: {name}") # 函数外: 张三 ← 没变!

🔗 nonlocal:在内层函数修改外层函数的变量

def outer():
    count = 0            # 外层函数的局部变量

    def inner():
        nonlocal count   # 声明:我要用外层的 count
        count += 1
        print(f"inner: {count}")

    inner()   # inner: 1
    inner()   # inner: 2
    inner()   # inner: 3
    print(f"outer: {count}")  # outer: 3

outer()
关键字
作用
使用场景
global
在函数内声明使用全局变量
计数器、配置修改
nonlocal
在内层函数声明使用外层函数的变量
闭包、装饰器

💡 能不用 global 就不用!
大量使用 global 会让代码难以理解和调试。
更好的做法:用参数传递、用 return 返回结果。


6. lambda 匿名函数

lambda 是"一行函数"——临时用一下,不需要正式定义。

# 普通函数
def double(x):
    return x * 2

# 等价的 lambda
double = lambda x: x * 2

print(double(5))   # 10

# lambda 的语法:lambda 参数: 表达式
# 只能写一行表达式,不能写多行语句

# 多个参数
add = lambda a, b: a + b
print(add(3, 5))   # 8

# 带默认值
greet = lambda name, msg="你好": f"{msg}, {name}!"
print(greet("张三"))            # 你好, 张三!
print(greet("张三", "早上好"))  # 早上好, 张三!

🎯 lambda 的常见用法

# 1. 排序的 key 参数
students = [("张三", 85), ("李四", 92), ("王五", 78)]
students.sort(key=lambda s: s[1])          # 按成绩排序
print(students)  # [('王五', 78), ('张三', 85), ('李四', 92)]

students.sort(key=lambda s: -s[1])         # 按成绩降序
print(students)  # [('李四', 92), ('张三', 85), ('王五', 78)]

# 2. sorted() 的 key
words = ["banana", "apple", "cherry", "date"]
by_length = sorted(words, key=lambda w: len(w))
print(by_length)  # ['date', 'apple', 'banana', 'cherry']

# 3. 字典按值排序
scores = {"张三": 85, "李四": 92, "王五": 78}
ranked = sorted(scores.items(), key=lambda x: -x[1])
print(ranked)  # [('李四', 92), ('张三', 85), ('王五', 78)]

# 4. 条件表达式
classify = lambda x: "正数" if x > 0 else ("零" if x == 0 else "负数")
print(classify(5))    # 正数
print(classify(-3))   # 负数
print(classify(0))    # 零

💡 lambda vs def 怎么选?
lambda:简单的一行表达式,临时用(排序 key、map 的函数)
def:复杂的逻辑、需要文档、需要多次调用

经验法则:如果逻辑超过一行,用 def


7. 闭包(Closure)入门

闭包 = 内层函数 + 记住了外层变量。即使外层函数已经执行完毕,内层函数仍然能访问那些变量。

def make_multiplier(n):
    """创建一个乘以 n 的函数"""
    def multiplier(x):
        return x * n     # n 来自外层函数
    return multiplier

# 创建两个"记住"不同 n 的函数
double = make_multiplier(2)    # n=2 被"记住"了
triple = make_multiplier(3)    # n=3 被"记住"了

print(double(5))   # 10(5 × 2)
print(triple(5))   # 15(5 × 3)

# make_multiplier 已经执行完了,但 n 还活在闭包里!
print(double.__closure__[0].cell_contents)  # 2
print(triple.__closure__[0].cell_contents)  # 3

🎯 闭包的实际用法

# 1. 计数器工厂
def make_counter(start=0):
    count = start
    def counter():
        nonlocal count
        count += 1
        return count
    return counter

c1 = make_counter()
c2 = make_counter(100)

print(c1())  # 1
print(c1())  # 2
print(c1())  # 3
print(c2())  # 101
print(c2())  # 102

# 2. 缓存函数(简易版)
def make_cache():
    cache = {}
    def cached_func(x):
        if x not in cache:
            print(f"计算 {x}...")
            cache[x] = x ** 2
        return cache[x]
    return cached_func

square = make_cache()
print(square(5))   # 计算 5... → 25
print(square(3))   # 计算 3... → 9
print(square(5))   # 25(直接返回缓存,不计算)

# 3. 权限检查器
def make_checker(required_role):
    def check(user_role):
        return user_role == required_role
    return check

is_admin = make_checker("admin")
is_editor = make_checker("editor")

print(is_admin("admin"))    # True
print(is_admin("user"))     # False
print(is_editor("editor"))  # True

💡 闭包三要素:
1. 有嵌套函数(函数里定义函数)
2. 内层函数引用了外层函数的变量
3. 外层函数返回内层函数

闭包是装饰器的基础——Day 34 会深入学习!


8. 实战练习

🎯 练习 1:万能格式化器(*args + **kwargs)

def format_report(title, *items, **options):
    """
    生成格式化报告

    参数:
        title: 报告标题
        *items: 报告条目(任意数量)
        **options: 格式选项(width, separator, uppercase)
    """
    width = options.get("width", 40)
    separator = options.get("separator", "-")
    uppercase = options.get("uppercase", False)

    print(separator * width)
    print(title.center(width))
    print(separator * width)

    for i, item in enumerate(items, 1):
        text = f"{i}. {item}"
        if uppercase:
            text = text.upper()
        print(text)

    print(separator * width)

format_report("购物清单", "牛奶", "面包", "鸡蛋", "水果", width=30)
format_report("待办事项", "写代码", "开会", "运动", separator="=", uppercase=True)

🎯 练习 2:运算符工厂(闭包)

def make_operator(op):
    """根据运算符创建对应的函数"""
    operators = {
        "+": lambda a, b: a + b,
        "-": lambda a, b: a - b,
        "*": lambda a, b: a * b,
        "/": lambda a, b: a / b if b != 0 else "除数不能为零",
        "**": lambda a, b: a ** b,
    }

    if op not in operators:
        return None

    func = operators[op]

    def operate(a, b):
        result = func(a, b)
        print(f"{a} {op} {b} = {result}")
        return result

    return operate

add = make_operator("+")
mul = make_operator("*")
pow_func = make_operator("**")

add(10, 5)      # 10 + 5 = 15
mul(10, 5)      # 10 * 5 = 50
pow_func(2, 10) # 2 ** 10 = 1024

🎯 练习 3:自动柯里化(闭包进阶)

def curry(func):
    """自动柯里化:把多参数函数变成链式调用"""
    import inspect
    params = inspect.signature(func).parameters
    n = len(params)

    def collect_args(args_so_far):
        def inner(*new_args):
            all_args = args_so_far + new_args
            if len(all_args) >= n:
                return func(*all_args[:n])
            return collect_args(all_args)
        return inner

    return collect_args(())

# 使用
@curry
def add3(a, b, c):
    return a + b + c

# 三种调用方式
print(add3(1, 2, 3))     # 6(一次传完)
print(add3(1)(2, 3))     # 6(分两次)
print(add3(1)(2)(3))     # 6(链式调用)

9. 今日小结

知识点
核心内容
*args
打包多余位置参数为元组
**kwargs
打包多余关键字参数为字典
参数顺序
位置专属 / 普通 *args 关键字专属 **kwargs
解包
*list
 展开为位置参数,**dict 展开为关键字参数
LEGB
Local → Enclosing → Global → Built-in
global
在函数内修改全局变量(少用为妙)
nonlocal
在内层函数修改外层函数变量
lambda
一行匿名函数,常用于排序 key
闭包
内层函数 + 记住外层变量 = 装饰器基础

🧠 记忆口诀:
星号打包 args 收,双星 kwargs 字典留。
LEGB 四层往外找,global 少用保平安。
lambda 一行够简洁,闭包装饰器在眼前。

🔮 预告: Day 15 内置函数 — map/filter/reducezip/enumeratesorted/reversedany/all。函数式编程的第一步!

轻松时刻:

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 16:35:46 HTTP/2.0 GET : https://f.mffb.com.cn/a/495199.html
  2. 运行时间 : 0.193775s [ 吞吐率:5.16req/s ] 内存消耗:4,493.59kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=ab354ae31df9eb21ab5dcb1b6360ae44
  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.000534s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000660s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.003503s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.021711s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000614s ]
  6. SELECT * FROM `set` [ RunTime:0.006355s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000743s ]
  8. SELECT * FROM `article` WHERE `id` = 495199 LIMIT 1 [ RunTime:0.018642s ]
  9. UPDATE `article` SET `lasttime` = 1783067746 WHERE `id` = 495199 [ RunTime:0.024419s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.009222s ]
  11. SELECT * FROM `article` WHERE `id` < 495199 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.010092s ]
  12. SELECT * FROM `article` WHERE `id` > 495199 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.021413s ]
  13. SELECT * FROM `article` WHERE `id` < 495199 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002926s ]
  14. SELECT * FROM `article` WHERE `id` < 495199 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002200s ]
  15. SELECT * FROM `article` WHERE `id` < 495199 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.003812s ]
0.195353s