当前位置:首页>python>Python 零基础100天—Day33 迭代器与生成器

Python 零基础100天—Day33 迭代器与生成器

  • 2026-07-03 21:57:45
Python 零基础100天—Day33 迭代器与生成器

🐍 迭代器与生成器 — 惰性求值的魔法

🕐 预计用时:2-3 小时 | 🎯 目标:掌握迭代协议、生成器函数、yield、惰性求值


📖 今日目录

  1. 什么是迭代?
  2. 可迭代对象 vs 迭代器
  3. __iter__ 与 __next__ — 迭代协议
  4. 自定义可迭代类
  5. yield 关键字 — 生成器函数
  6. 生成器的工作原理
  7. 生成器表达式
  8. yield from — 委托生成器
  9. 实战:大文件逐行处理
  10. 实战:无限序列与管道
  11. 今日小结

1. 什么是迭代?

迭代(Iteration)就是"一个一个地取元素"——for 循环就是迭代。

# 你每天都在迭代,只是不知道它叫这个名字
for i in [1, 2, 3]:
    print(i)

for char in "hello":
    print(char)

for line in open("data.txt"):
    print(line.strip())

# 这些都是迭代!背后都是同一个协议:__iter__ + __next__

💡 为什么要学迭代器?
1. 理解 for 循环的底层原理
2. 处理大数据集时节省内存(惰性求值)
3. 自定义可迭代对象(让你的类支持 for 循环)
4. 生成器是异步编程的基础(Day38)


2. 可迭代对象 vs 迭代器

这两个概念容易混淆,但它们是不同的:

概念
说明
例子
协议方法
可迭代对象 (Iterable)
可以被 for 循环遍历的对象
list, str, dict, range
__iter__()
迭代器 (Iterator)
实际执行迭代的对象,有"指针"
iter([1,2,3])
__iter__()
 + __next__()
from collections.abc import Iterable, Iterator

# 可迭代对象(有 __iter__ 方法)
print(isinstance([1, 2, 3], Iterable))  # True
print(isinstance("hello", Iterable))    # True
print(isinstance(123, Iterable))         # False

# 迭代器(有 __iter__ 和 __next__ 方法)
it = iter([1, 2, 3])
print(isinstance(it, Iterator))          # True
print(isinstance([1, 2, 3], Iterator))   # False(列表不是迭代器!)

# 关键区别:
# 可迭代对象 → 可以创建迭代器(调用 iter())
# 迭代器     → 可以逐个取元素(调用 next())
# 手动迭代
nums = [10, 20, 30]

# iter() 从可迭代对象创建迭代器
it = iter(nums)

# next() 逐个取元素
print(next(it))  # 10
print(next(it))  # 20
print(next(it))  # 30
print(next(it))  # ❌ StopIteration(没有更多元素了)

# for 循环本质上就是:
# it = iter(iterable)
# while True:
#     try:
#         value = next(it)
#         # 循环体
#     except StopIteration:
#         break

⚠️ 核心区别:
• 列表是可迭代对象,但不是迭代器(不能直接 next()
• iter([1,2,3]) 返回的才是迭代器
• 迭代器用完就没了(只能遍历一次)


3. __iter__ 与 __next__ — 迭代协议

迭代协议就是两个魔法方法__iter__() 返回迭代器,__next__() 返回下一个元素。

class Countdown:
    """倒计时迭代器"""

    def __init__(self, start):
        self.current = start

    def __iter__(self):
        """返回迭代器本身"""
        return self

    def __next__(self):
        """返回下一个值"""
        if self.current <= 0:
            raise StopIteration  # 迭代结束

        value = self.current
        self.current -= 1
        return value

# 使用
for num in Countdown(5):
    print(num, end=" ")
# 输出: 5 4 3 2 1
# 手动使用迭代器
cd = Countdown(3)
print(next(cd))  # 3
print(next(cd))  # 2
print(next(cd))  # 1
# print(next(cd))  # StopIteration!

4. 自定义可迭代类

class NumberRange:
    """模拟 range() 的自定义可迭代对象

    可以被多次迭代(每次创建新的迭代器)
    """

    def __init__(self, start, end):
        self.start = start
        self.end = end

    def __iter__(self):
        """每次调用返回一个新的迭代器"""
        return NumberRangeIterator(self.start, self.end)

    def __len__(self):
        return self.end - self.start


class NumberRangeIterator:
    """迭代器类"""

    def __init__(self, start, end):
        self.current = start
        self.end = end

    def __iter__(self):
        return self

    def __next__(self):
        if self.current >= self.end:
            raise StopIteration
        value = self.current
        self.current += 1
        return value


# 使用
nums = NumberRange(1, 6)
print(list(nums))  # [1, 2, 3, 4, 5]

# 可以多次迭代(因为 __iter__ 每次返回新迭代器)
for n in nums:
    print(n, end=" ")  # 1 2 3 4 5
print()
for n in nums:
    print(n, end=" ")  # 1 2 3 4 5(可以再来一次!)

💡 分离设计的好处:
• NumberRange(可迭代对象):存储配置,可以多次迭代
• NumberRangeIterator(迭代器):存储状态,只能用一次
• 这就是 Python 标准库 list、dict、str 的设计模式


5. yield 关键字 — 生成器函数

生成器(Generator)是用 yield 创建迭代器的简便方式——不用手写类,一个函数搞定。

# 普通函数:一次返回所有值
def countdown_list(n):
    result = []
    while n > 0:
        result.append(n)
        n -= 1
    return result

# 生成器函数:每次 yield 一个值
def countdown_gen(n):
    while n > 0:
        yield n  # 暂停,返回值,下次从这里继续
        n -= 1

# 使用
for num in countdown_gen(5):
    print(num, end=" ")
# 输出: 5 4 3 2 1
# yield 的神奇之处:函数状态被保留!
def simple_gen():
    print("第一步")
    yield 1
    print("第二步")
    yield 2
    print("第三步")
    yield 3
    print("结束")

gen = simple_gen()

print(next(gen))  # 执行到第一个 yield
# 输出:
#   第一步
#   1

print(next(gen))  # 从第一个 yield 后继续,执行到第二个 yield
# 输出:
#   第二步
#   2

print(next(gen))  # 从第二个 yield 后继续
# 输出:
#   第三步
#   3

# next(gen)  # StopIteration(函数执行完毕)

💡 yield 的本质:
1. 遇到 yield → 暂停函数,返回值
2. 下次 next() → 从暂停处继续执行
3. 函数执行完 → 抛出 StopIteration
4. 函数的局部变量全部保留!


6. 生成器的工作原理

# 生成器 vs 列表:内存对比
import sys

# 列表:一次性创建所有元素
big_list = [i for i in range(1000000)]
print(f"列表大小: {sys.getsizeof(big_list) / 1024 / 1024:.1f} MB")  # ~8 MB

# 生成器:每次只创建一个元素
big_gen = (i for i in range(1000000))
print(f"生成器大小: {sys.getsizeof(big_gen)} bytes")  # ~200 bytes!

# 生成器比列表节省了几万倍内存!
# 生成器只能遍历一次!
gen = (i * 2 for i in range(5))

# 第一次遍历
for x in gen:
    print(x, end=" ")  # 0 2 4 6 8
print()

# 第二次遍历(什么都没有!)
for x in gen:
    print(x, end=" ")  # (空)
print()
# 生成器是"惰性"的——按需计算
def fibonacci():
    """无限斐波那契数列"""
    a, b = 0, 1
    while True:
        yield a
        a, b = b, a + b

# 取前 10 个斐波那契数
fib = fibonacci()
for _ in range(10):
    print(next(fib), end=" ")
# 0 1 1 2 3 5 8 13 21 34

7. 生成器表达式

生成器表达式是列表推导式的"惰性版"——用圆括号代替方括号。

# 列表推导式:一次性创建所有元素
squares_list = [x**2 for x in range(10)]
print(squares_list)  # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

# 生成器表达式:按需生成元素
squares_gen = (x**2 for x in range(10))
print(squares_gen)   # <generator object <genexpr> at 0x...>

# 生成器可以直接传给 sum/max/min/sorted 等函数
print(sum(x**2 for x in range(10)))      # 285(不需要额外括号)
print(max(x**2 for x in range(10)))      # 81
print(sorted(x**2 for x in range(10)))   # [0, 1, 4, 9, ...]

# 配合 any/all
print(any(x > 50 for x in range(10)))    # False
print(all(x >= 0 for x in range(10)))    # True

💡 生成器表达式 vs 列表推导式:
• 遍历一次 → 用生成器(省内存)
• 遍历多次 → 用列表(可重复使用)
• 传给 sum/any/all → 用生成器(不需要额外括号)


8. yield from — 委托生成器

yield from 把迭代委托给另一个可迭代对象——简化嵌套生成器。

# 不用 yield from:需要手动 for 循环
def chain_manual(*iterables):
    for it in iterables:
        for item in it:
            yield item

# 用 yield from:一行搞定
def chain(*iterables):
    for it in iterables:
        yield from it  # 直接委托

# 使用
result = list(chain([1, 2], [3, 4], [5, 6]))
print(result)  # [1, 2, 3, 4, 5, 6]
# 递归生成器:展平嵌套列表
def flatten(nested):
    """展平任意深度的嵌套列表"""
    for item in nested:
        if isinstance(item, (list, tuple)):
            yield from flatten(item)  # 递归委托
        else:
            yield item

# 使用
nested = [1, [2, 3], [4, [5, 6, [7, 8]]]]
print(list(flatten(nested)))
# [1, 2, 3, 4, 5, 6, 7, 8]

9. 实战:大文件逐行处理

处理几 GB 的日志文件?不能全部加载到内存,用生成器逐行读取。

def read_large_file(filepath, encoding="utf-8"):
    """逐行读取大文件(生成器)"""
    with open(filepath, "r", encoding=encoding) as f:
        for line in f:
            yield line.rstrip("\n")


def filter_lines(lines, keyword):
    """过滤包含关键词的行(生成器)"""
    for line in lines:
        if keyword in line:
            yield line


def parse_log_lines(lines):
    """解析日志行(生成器)"""
    import re
    pattern = r"\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\] \[(\w+)\] (.+)"
    for line in lines:
        match = re.match(pattern, line)
        if match:
            yield {
                "time": match.group(1),
                "level": match.group(2),
                "message": match.group(3)
            }


# 链式调用:读取 → 过滤 → 解析
lines = read_large_file("app.log")
errors = filter_lines(lines, "ERROR")
parsed = parse_log_lines(errors)

for entry in parsed:
    print(f"🚨 [{entry['time']}] {entry['message']}")
# 统计大文件的行数(不占内存)
def count_lines(filepath):
    """统计文件行数"""
    count = 0
    for _ in read_large_file(filepath):
        count += 1
    return count

# 统计各级别日志数量
def count_by_level(filepath):
    """按日志级别统计"""
    from collections import Counter
    counter = Counter()
    for line in read_large_file(filepath):
        if "[ERROR]" in line:
            counter["ERROR"] += 1
        elif "[WARN]" in line:
            counter["WARN"] += 1
        elif "[INFO]" in line:
            counter["INFO"] += 1
    return counter

💡 生成器管道模式:
每个函数都是一个"处理器",通过生成器串联起来。
读取 → 过滤 → 转换 → 聚合
数据像水一样流过管道,每个环节只处理一行,内存占用恒定!


10. 实战:无限序列与管道

无限序列

def count_from(start=0, step=1):
    """无限计数器"""
    n = start
    while True:
        yield n
        n += step

def take(n, iterable):
    """从可迭代对象中取前 n 个"""
    for i, item in enumerate(iterable):
        if i >= n:
            break
        yield item

def skip(n, iterable):
    """跳过前 n 个"""
    for i, item in enumerate(iterable):
        if i >= n:
            yield item

# 组合使用
counter = count_from(1)
first_5 = take(5, counter)
print(list(first_5))  # [1, 2, 3, 4, 5]

# 从 10 开始,跳过 3 个,取 5 个
numbers = count_from(10)
result = list(take(5, skip(3, numbers)))
print(result)  # [13, 14, 15, 16, 17]

数据处理管道

def read_data():
    """数据源"""
    data = [
        {"name": "张三", "age": 25, "salary": 10000},
        {"name": "李四", "age": 30, "salary": 15000},
        {"name": "王五", "age": 22, "salary": 8000},
        {"name": "赵六", "age": 35, "salary": 20000},
        {"name": "钱七", "age": 28, "salary": 12000},
    ]
    for item in data:
        yield item

def filter_by(data, key, min_val=None, max_val=None):
    """按条件过滤"""
    for item in data:
        value = item[key]
        if min_val is not None and value < min_val:
            continue
        if max_val is not None and value > max_val:
            continue
        yield item

def transform(data, func):
    """转换数据"""
    for item in data:
        yield func(item)

def collect(data):
    """收集结果"""
    return list(data)

# 构建管道:读取 → 过滤 → 转换 → 收集
pipeline = read_data()
pipeline = filter_by(pipeline, "age", min_val=25)
pipeline = filter_by(pipeline, "salary", min_val=10000)
pipeline = transform(pipeline, lambda x: f"{x['name']} ({x['age']}岁) 月薪{x['salary']}")

result = collect(pipeline)
for r in result:
    print(f"  {r}")

# 输出:
#   张三 (25岁) 月薪10000
#   李四 (30岁) 月薪15000
#   赵六 (35岁) 月薪20000
#   钱七 (28岁) 月薪12000

itertools 标准库

import itertools

# count: 无限计数
for i in itertools.count(10, 2):
    if i > 20:
        break
    print(i, end=" ")  # 10 12 14 16 18 20

# cycle: 无限循环
colors = itertools.cycle(["红", "绿", "蓝"])
for _, color in zip(range(6), colors):
    print(color, end=" ")  # 红 绿 蓝 红 绿 蓝

# chain: 连接多个可迭代对象
combined = list(itertools.chain([1, 2], [3, 4], [5, 6]))
print(combined)  # [1, 2, 3, 4, 5, 6]

# islice: 切片迭代器
result = list(itertools.islice(itertools.count(), 5, 10))
print(result)  # [5, 6, 7, 8, 9]

# groupby: 分组
data = sorted(["apple", "avocado", "banana", "blueberry", "cherry"], key=lambda x: x[0])
for key, group in itertools.groupby(data, key=lambda x: x[0]):
    print(f"{key}: {list(group)}")
# a: ['apple', 'avocado']
# b: ['banana', 'blueberry']
# c: ['cherry']

11. 今日小结

概念
说明
关键方法/关键字
可迭代对象
能被 for 遍历
__iter__()
迭代器
执行迭代的对象
__iter__()
 + __next__()
生成器函数
用 yield 创建迭代器
yield
生成器表达式
惰性版列表推导式
(x for x in ...)
yield from
委托给另一个迭代器
yield from iterable

核心要点

  • ✅ iter(obj) 创建迭代器,next(it) 取下一个元素
  • ✅ 迭代器只能遍历一次,可迭代对象可以多次遍历
  • ✅ yield 暂停函数并保留状态,下次从暂停处继续
  • ✅ 生成器节省内存:按需计算,不一次性创建所有元素
  • ✅ 生成器表达式:(x for x in ...) 替代 [x for x in ...]
  • ✅ yield from 委托迭代,简化嵌套生成器
  • ✅ 生成器管道模式:读取 → 过滤 → 转换 → 聚合
  • ✅ itertools 提供 count/cycle/chain/groupby 等工具

🎯 练习建议:
1. 写一个生成器,生成所有素数(无限序列)
2. 写一个 map_gen(func, iterable) 函数,模拟内置 map() 的惰性版本
3. 用生成器管道处理一个 CSV 文件:读取 → 过滤空行 → 转换类型 → 输出


📚 Day33 完成!明天学习闭包与装饰器 — 函数的"包装艺术"

轻松时刻:

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-04 03:11:24 HTTP/2.0 GET : https://f.mffb.com.cn/a/499182.html
  2. 运行时间 : 0.137810s [ 吞吐率:7.26req/s ] 内存消耗:4,324.12kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=a92b8b4ac69f8e3980914186c6e5d4fd
  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.000606s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000843s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000341s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000295s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000500s ]
  6. SELECT * FROM `set` [ RunTime:0.000196s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000625s ]
  8. SELECT * FROM `article` WHERE `id` = 499182 LIMIT 1 [ RunTime:0.013012s ]
  9. UPDATE `article` SET `lasttime` = 1783105884 WHERE `id` = 499182 [ RunTime:0.005156s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000352s ]
  11. SELECT * FROM `article` WHERE `id` < 499182 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000468s ]
  12. SELECT * FROM `article` WHERE `id` > 499182 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000425s ]
  13. SELECT * FROM `article` WHERE `id` < 499182 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000638s ]
  14. SELECT * FROM `article` WHERE `id` < 499182 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.005707s ]
  15. SELECT * FROM `article` WHERE `id` < 499182 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.033524s ]
0.140563s