当前位置:首页>python>Python学习--生成器详解

Python学习--生成器详解

  • 2026-04-18 17:25:18
Python学习--生成器详解

一、什么是生成器?

1. 生成器的定义

生成器(Generator) 是一种特殊的迭代器,它使用 yield 关键字而不是 return 来返回值。生成器函数在每次产生值时会暂停执行,下次调用时从暂停处继续执行。

2. 生成器 vs 普通函数 vs 迭代器

# 普通函数:一次性返回所有结果def normal_function():    result = []    for i in range(5):        result.append(i)    return result# 生成器函数:逐个产生结果def generator_function():    for i in range(5):        yield i# 迭代器:需要实现 __iter__ 和 __next__class IteratorClass:    def __init__(self):        self.n = 0    def __iter__(self):        return self    def __next__(self):        if self.n < 5:            value = self.n            self.n += 1            return value        raise StopIteration# 使用对比print("普通函数:", normal_function())print("生成器:"list(generator_function()))print("迭代器:"list(IteratorClass()))

二、创建生成器

1. 生成器函数(yield)

def simple_generator():    """最简单的生成器"""    yield 1    yield 2    yield 3# 使用gen = simple_generator()print(next(gen))  # 1print(next(gen))  # 2print(next(gen))  # 3# print(next(gen))  # StopIteration# for 循环自动处理 StopIterationfor value in simple_generator():    print(value, end=' ')  # 1 2 3print()

2. 生成器表达式

# 列表推导式list_comp = [x**2 for x in range(10)]print(f"列表推导式: {list_comp}")print(f"类型: {type(list_comp)}")# 生成器表达式gen_exp = (x**2 for x in range(10))print(f"生成器表达式: {gen_exp}")print(f"类型: {type(gen_exp)}")# 逐个取值for value in gen_exp:    print(value, end=' ')    if value > 20:        breakprint()# 内存对比import syslist_comp = [x for x in range(1000000)]gen_exp = (x for x in range(1000000))print(f"列表内存: {sys.getsizeof(list_comp) / 1024:.2f} KB")print(f"生成器内存: {sys.getsizeof(gen_exp) / 1024:.2f} KB")

3. yield 的工作原理

def generator_with_print():    """演示 yield 的执行流程"""    print("生成器开始执行")    yield 1    print("继续执行,准备 yield 2")    yield 2    print("继续执行,准备 yield 3")    yield 3    print("生成器结束")# 逐步执行gen = generator_with_print()print("第一次调用 next:")value = next(gen)print(f"得到: {value}\n")print("第二次调用 next:")value = next(gen)print(f"得到: {value}\n")print("第三次调用 next:")value = next(gen)print(f"得到: {value}\n")try:    print("第四次调用 next:")    value = next(gen)except StopIteration:    print("生成器已耗尽")

三、生成器的高级特性

1. send() - 向生成器发送值

def echo_generator():    """接收并返回发送的值"""    print("生成器启动")    while True:        received = yield        print(f"收到: {received}")gen = echo_generator()next(gen)  # 启动生成器gen.send("Hello")  # 发送值gen.send("World")gen.send("!")# 实际应用:累加器def accumulator():    """累加器生成器"""    total = 0    while True:        value = yield total        if value is not None:            total += valueacc = accumulator()next(acc)  # 启动print(acc.send(10))  # 10print(acc.send(20))  # 30print(acc.send(30))  # 60

2. throw() - 向生成器抛出异常

def generator_with_exception():    """处理异常的生成器"""    try:        yield 1        yield 2        yield 3    except ValueError as e:        print(f"捕获到异常: {e}")        yield "异常处理完成"gen = generator_with_exception()print(next(gen))  # 1print(next(gen))  # 2# 抛出异常result = gen.throw(ValueError("自定义错误"))print(result)  # "异常处理完成"

3. close() - 关闭生成器

def closable_generator():    """可关闭的生成器"""    try:        yield 1        yield 2        yield 3    except GeneratorExit:        print("生成器被关闭,执行清理")        # 可以在这里做清理工作        # 注意:不能 yield,只能 returngen = closable_generator()print(next(gen))  # 1print(next(gen))  # 2gen.close()  # 关闭生成器# print(next(gen))  # StopIteration

四、最佳实践和注意事项

1. 生成器设计模式

class GeneratorPatterns:    """生成器设计模式"""    @staticmethod    def producer():        """生产者模式"""        for i in range(5):            print(f"生产: {i}")            yield i    @staticmethod    def consumer(generator):        """消费者模式"""        for item in generator:            print(f"消费: {item}")    @staticmethod    def pipeline():        """管道模式"""        def stage1():            for i in range(5):                yield i * 2        def stage2(input_gen):            for item in input_gen:                yield item + 1        # 构建管道        s1 = stage1()        s2 = stage2(s1)        return s2    @staticmethod    def coroutine():        """协程模式"""        def coroutine_example():            while True:                received = yield                print(f"处理: {received}")        co = coroutine_example()        next(co)  # 启动        co.send("数据1")        co.send("数据2")

2. 常见陷阱

# 陷阱1:生成器只能遍历一次def trap_once():    gen = (x for x in range(3))    print(list(gen))  # [0, 1, 2]    print(list(gen))  # [] - 已经空了# 正确做法:需要多次遍历时使用列表def fix_once():    data = [x for x in range(3)]  # 列表    print(data)    print(data)# 陷阱2:在生成器内部修改外部变量def trap_modify():    x = 10    gen = (x for _ in range(3))    x = 20  # 不影响生成器    print(list(gen))  # [10, 10, 10]# 陷阱3:生成器表达式的作用域def trap_scope():    gen = (x for x in range(3))    x = 100  # 不影响生成器内的 x    print(list(gen))  # [0, 1, 2]# 陷阱4:过早耗尽生成器def trap_exhaust():    def process(items):        if items:  # 这里会消耗生成器            return sum(items)        return 0    gen = (x for x in range(5))    # print(process(gen))  # 错误:gen 被消耗    # print(list(gen))  # [] - 已经空了    # 正确做法    items = list(gen)  # 先转换为列表    print(process(items))# 陷阱5:在生成器中使用递归没有 yield fromdef trap_recursion():    def flatten_wrong(nested):        for item in nested:            if isinstance(item, (listtuple)):                flatten_wrong(item)  # 错误:没有 yield            else:                yield item    def flatten_correct(nested):        for item in nested:            if isinstance(item, (listtuple)):                yield from flatten_correct(item)            else:                yield item    nested = [1, [2, [34], 5]]    print(list(flatten_correct(nested)))  # [1, 2, 3, 4, 5]

3. 性能优化技巧

class GeneratorOptimization:    """生成器优化技巧"""    @staticmethod    def use_local_variables():        """使用局部变量加速"""        def slow_generator(n):            for i in range(n):                yield i ** 2        def fast_generator(n):            square = lambda x: x ** 2  # 局部变量            for i in range(n):                yield square(i)        # 性能对比        import time        n = 1000000        start = time.perf_counter()        sum(slow_generator(n))        slow_time = time.perf_counter() - start        start = time.perf_counter()        sum(fast_generator(n))        fast_time = time.perf_counter() - start        print(f"普通: {slow_time:.3f}s")        print(f"优化: {fast_time:.3f}s")        print(f"提升: {(slow_time/fast_time - 1)*100:.1f}%")    @staticmethod    def avoid_yield_in_loops():        """避免在循环中yield"""        # 不好的做法        def bad():            for i in range(10):                yield i            for i in range(1020):                yield i        # 好的做法:使用 yield from        def good():            yield from range(10)            yield from range(1020)    @staticmethod    def use_itertools():        """使用 itertools 优化"""        from itertools import islice, chain, count        # 手动实现        def take_manual(n, iterable):            for i, x in enumerate(iterable):                if i >= n:                    break                yield x        # 使用 itertools        def take_itertools(n, iterable):            yield from islice(iterable, n)        data = range(1000000)        print(list(take_itertools(5, data)))  # [0, 1, 2, 3, 4]

总结

1. 生成器的优点

  • 内存高效:一次只产生一个值

  • 惰性计算:需要时才计算

  • 无限序列:可以表示无限数据流

  • 简洁代码:比实现迭代器类更简单

  • 协程支持:可以实现协作式多任务

2. 适用场景

 场景
是否适合
原因
 处理大文件
✅ 非常适合
内存友好,逐行处理
 无限序列
✅ 非常适合
可以无限生成
 数据管道
✅ 非常适合
可以链式处理
 随机访问
❌ 不适合
只能顺序访问
 多次遍历
❌ 不适合
只能遍历一次
 小数据集
⚠️ 可能过度
简单列表可能更简单

3. 选择指南

# 什么时候使用生成器?def generator_guide():    """生成器使用指南"""    # ✅ 适合使用生成器    # 1. 处理大数据集    def process_large_file():        for line in open('large_file.txt'):            yield process(line)    # 2. 无限序列    def fibonacci():        a, b = 01        while True:            yield a            a, b = b, a + b    # 3. 数据管道    def pipeline():        data = (x for x in range(100))        data = (x**2 for x in data)        data = (x for x in data if x % 2 == 0)        return data    # ❌ 不适合使用生成器    # 1. 需要随机访问    def bad_for_random():        gen = (x for x in range(10))        # 不能 gen[5]    # 2. 需要多次遍历    def bad_for_multiple():        gen = (x for x in range(10))        # list(gen) 只能用一次    # 3. 数据量小且需要重复使用    def better_as_list():        data = [12345]  # 小数据集用列表

4. 最佳实践总结

class GeneratorBestPractices:    """生成器最佳实践"""    # 1. 使用有意义的名称    def generate_numbers(self):        """生成数字"""        yield from range(10)    # 2. 提供文档字符串    def fibonacci(self):        """生成斐波那契数列(无限)"""        a, b = 01        while True:            yield a            a, b = b, a + b    # 3. 处理异常    def safe_generator(self):        try:            yield 1            yield 2        except GeneratorExit:            print("清理资源")        finally:            print("确保清理")    # 4. 使用类型提示    from typing import Generator    def typed_generator(self, n: int) -> Generator[intNoneNone]:        """带类型提示的生成器"""        for i in range(n):            yield i    # 5. 考虑使用 yield from    def combined(self):        yield from self.generate_numbers()        yield from self.fibonacci()    # 6. 避免副作用    def pure_generator(self, data):        """纯生成器,没有副作用"""        for item in data:            yield item ** 2  # 不修改输入

生成器是 Python 中强大的特性,正确使用可以写出内存高效、可维护的代码。它们是处理大数据流、实现惰性计算和构建数据处理管道的理想工具。

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-04-21 21:44:00 HTTP/2.0 GET : https://f.mffb.com.cn/a/484171.html
  2. 运行时间 : 0.307738s [ 吞吐率:3.25req/s ] 内存消耗:4,907.30kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=8e53a838e9bf00b8d384ae6e4952023f
  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.000682s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001038s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000432s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000434s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000909s ]
  6. SELECT * FROM `set` [ RunTime:0.000378s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000952s ]
  8. SELECT * FROM `article` WHERE `id` = 484171 LIMIT 1 [ RunTime:0.013300s ]
  9. UPDATE `article` SET `lasttime` = 1776779040 WHERE `id` = 484171 [ RunTime:0.066667s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000583s ]
  11. SELECT * FROM `article` WHERE `id` < 484171 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000813s ]
  12. SELECT * FROM `article` WHERE `id` > 484171 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000687s ]
  13. SELECT * FROM `article` WHERE `id` < 484171 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.014337s ]
  14. SELECT * FROM `article` WHERE `id` < 484171 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002349s ]
  15. SELECT * FROM `article` WHERE `id` < 484171 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001747s ]
0.310520s