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

Python学习--迭代器详解

  • 2026-03-27 23:02:34
Python学习--迭代器详解

一、什么是迭代器?

1. 迭代器的定义

迭代器是一个可以记住遍历位置的对象。它实现了迭代器协议,即包含 __iter__() 和 __next__() 方法。

2. 迭代器协议

# 迭代器必须实现的两个方法:- __iter__(): 返回迭代器对象本身- __next__(): 返回下一个元素,没有元素时抛出 StopIteration

3. 可迭代对象 vs 迭代器

# 可迭代对象 (Iterable): 可以返回迭代器的对象(实现了 __iter__# 迭代器 (Iterator): 可以逐个返回元素的对象(实现了 __iter__ 和 __next__# 关系图:# 可迭代对象 ──(iter())──> 迭代器 ──(next())──> 元素

二、基础概念

1. 最简单的例子

# 列表是可迭代对象,但不是迭代器my_list = [123]print(f"列表是可迭代对象: {hasattr(my_list, '__iter__')}")print(f"列表是迭代器: {hasattr(my_list, '__next__')}")# 获取迭代器iterator = iter(my_list)print(f"迭代器是可迭代对象: {hasattr(iterator, '__iter__')}")print(f"迭代器是迭代器: {hasattr(iterator, '__next__')}")# 使用迭代器print(next(iterator))  # 1print(next(iterator))  # 2print(next(iterator))  # 3# print(next(iterator))  # StopIteration

2. 迭代器的工作原理

# for 循环的工作原理my_list = [123]# Python 内部是这样做的:iterator = iter(my_list)  # 1. 获取迭代器while True:    try:        item = next(iterator)  # 2. 获取下一个元素        print(item)             # 3. 处理元素    except StopIteration:       # 4. 捕获结束信号        break                    # 5. 退出循环# 等价于:for item in my_list:    print(item)

三、自定义迭代器

1. 最简单的迭代器

class Counter:    """计数器迭代器"""    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# 使用counter = Counter(15)for num in counter:    print(num, end=' ')  # 1 2 3 4print()# 注意:迭代器只能使用一次print(list(counter))  # [] 已经用完了

2. 无限迭代器

class FibonacciIterator:    """斐波那契数列迭代器(无限)"""    def __init__(self):        self.a = 0        self.b = 1    def __iter__(self):        return self    def __next__(self):        value = self.a        self.a, self.b = self.b, self.a + self.b        return value# 使用fib = FibonacciIterator()for i, num in enumerate(fib):    print(num, end=' ')    if i >= 10:  # 取前10个        breakprint()  # 0 1 1 2 3 5 8 13 21 34 55# 注意:无限迭代器需要手动停止

3. 可重置的迭代器

class ResettableIterator:    """可重置的迭代器"""    def __init__(self, data):        self.data = data        self.index = 0    def __iter__(self):        return self    def __next__(self):        if self.index >= len(self.data):            raise StopIteration        value = self.data[self.index]        self.index += 1        return value    def reset(self):        """重置迭代器"""        self.index = 0# 使用it = ResettableIterator([12345])print("第一次遍历:")for item in it:    print(item, end=' ')print()print("重置后再次遍历:")it.reset()for item in it:    print(item, end=' ')print()

四、内置迭代器工具

1. iter() 函数

# 从可迭代对象创建迭代器my_list = [123]it = iter(my_list)print(next(it))  # 1# 使用哨兵值创建迭代器import sysdef read_until_q():    """读取输入直到输入 'q'"""    return input("输入 (输入 'q' 退出): ")# 当函数返回 'q' 时停止for line in iter(read_until_q, 'q'):    print(f"你输入了: {line}")

2. next() 函数

it = iter([123])# 基本使用print(next(it))  # 1# 带默认值print(next(it, '没有更多了'))  # 2print(next(it, '没有更多了'))  # 3print(next(it, '没有更多了'))  # '没有更多了'

3. enumerate() - 枚举迭代器

fruits = ['apple''banana''orange']# 获取索引和值for i, fruit in enumerate(fruits):    print(f"{i}{fruit}")# 指定起始索引for i, fruit in enumerate(fruits, start=1):    print(f"{i}{fruit}")

4. zip() - 并行迭代

names = ['Alice''Bob''Charlie']ages = [253035]cities = ['New York''London''Tokyo']# 并行迭代多个序列for name, age, city in zip(names, ages, cities):    print(f"{name} is {age} years old, lives in {city}")# 处理不等长序列numbers = [123]letters = ['a''b']for num, letter in zip(numbers, letters):    print(f"{num}:{letter}")  # 只输出两个,第三个被忽略# 使用 zip_longest 处理不等长from itertools import zip_longestfor num, letter in zip_longest(numbers, letters, fillvalue='?'):    print(f"{num}:{letter}")

五、最佳实践和注意事项

1. 迭代器使用原则

class IteratorBestPractices:    """迭代器最佳实践"""    # 1. 一次性的迭代器    def once_demo(self):        it = iter([123])        print(list(it))  # [1, 2, 3]        print(list(it))  # [] - 已经用完了    # 2. 使用生成器简化    def generator_demo(self):        def countdown(n):            while n > 0:                yield n                n -= 1        # 简单清晰        for x in countdown(5):            print(x)    # 3. 处理大文件    def file_processing_demo(self):        def read_lines(file_path):            with open(file_path) as f:                for line in f:                    yield line.strip()        # 内存友好        for line in read_lines('large_file.txt'):            process(line)    # 4. 提前退出    def early_exit_demo(self):        def find_first(iterable, predicate):            for item in iterable:                if predicate(item):                    return item            return None        # 找到就停止,不继续遍历        result = find_first(range(1000000), lambda x: x > 500000)

2. 常见陷阱

# 陷阱1:多次使用迭代器it = iter([123])print(list(it))  # [1, 2, 3]print(list(it))  # [] - 已经空了# 正确做法:重新创建it = iter([123])print(list(it))it = iter([123])  # 重新创建print(list(it))# 陷阱2:修改可迭代对象data = [1234]for item in data:    if item == 2:        data.remove(item)  # 危险!会跳过元素print(data)  # [1, 3, 4] - 3 被跳过了# 正确做法:创建新列表data = [1234]data = [x for x in data if x != 2]# 陷阱3:迭代器耗尽def process_items(items):    for item in items:        yield process(item)items = process_items(data)if items:  # 错误:迭代器总是 True    print("有数据")# 正确做法items = list(process_items(data))  # 转换为列表if items:    print("有数据")# 陷阱4:无限迭代器没有停止条件def infinite():    i = 0    while True:        yield i        i += 1gen = infinite()# for x in gen:  # 无限循环!#     print(x)# 正确做法:设置限制for i, x in enumerate(gen):    if i >= 10:        break    print(x)

3. 自定义迭代器模板

class IteratorTemplate:    """迭代器模板"""    def __init__(self, data):        self.data = data        self.index = 0    def __iter__(self):        """返回迭代器本身"""        return self    def __next__(self):        """返回下一个元素"""        if self.index >= len(self.data):            raise StopIteration        value = self._process_item(self.data[self.index])        self.index += 1        return value    def _process_item(self, item):        """处理单个项目(可被子类重写)"""        return item    def reset(self):        """重置迭代器"""        self.index = 0    def __len__(self):        """返回可迭代长度"""        return len(self.data) - self.index    def __repr__(self):        return f"{self.__class__.__name__}(剩余: {len(self)})"# 使用class SquareIterator(IteratorTemplate):    def _process_item(self, item):        return item ** 2it = SquareIterator([12345])for value in it:    print(value, end=' ')  # 1 4 9 16 25print()print(it)  # SquareIterator(剩余: 0)

总结

迭代器的优点:

  1. 内存高效:一次只产生一个元素

  2. 惰性计算:需要时才计算

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

  4. 统一接口:所有迭代器使用相同的方式操作

何时使用迭代器:

  • 处理大数据集

  • 流式数据处理

  • 需要惰性计算的场景

  • 表示无限序列

  • 需要统一的遍历接口

何时避免使用迭代器:

  • 需要随机访问

  • 需要多次遍历

  • 数据量很小

  • 需要索引操作

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-28 12:33:13 HTTP/2.0 GET : https://f.mffb.com.cn/a/483454.html
  2. 运行时间 : 0.231259s [ 吞吐率:4.32req/s ] 内存消耗:4,661.96kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=a842e0afb9a2f7ae3a7ef4cfd1ff8d34
  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.001136s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001481s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000671s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000639s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001431s ]
  6. SELECT * FROM `set` [ RunTime:0.000528s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001495s ]
  8. SELECT * FROM `article` WHERE `id` = 483454 LIMIT 1 [ RunTime:0.009654s ]
  9. UPDATE `article` SET `lasttime` = 1774672393 WHERE `id` = 483454 [ RunTime:0.010951s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000727s ]
  11. SELECT * FROM `article` WHERE `id` < 483454 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001222s ]
  12. SELECT * FROM `article` WHERE `id` > 483454 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.002193s ]
  13. SELECT * FROM `article` WHERE `id` < 483454 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.008061s ]
  14. SELECT * FROM `article` WHERE `id` < 483454 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.017303s ]
  15. SELECT * FROM `article` WHERE `id` < 483454 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.011245s ]
0.235099s