当前位置:首页>python>Python学习--类相关特殊方法详解

Python学习--类相关特殊方法详解

  • 2026-03-26 09:19:25
Python学习--类相关特殊方法详解

一、类相关方法概述

1. 类操作的特殊方法

 方法
作用
触发时机
__init_subclass__
子类初始化
创建子类时
__subclasshook__
自定义子类检查
issubclass()
 调用时
__class_getitem__
泛型类支持
cls[T]
 语法时

2. 元类 vs 类方法

# 元类方法(影响类创建)class Meta(type):    def __new__(cls, name, bases, namespace):        ...# 类相关方法(影响子类行为)class Base:    def __init_subclass__(cls, **kwargs):        ...    @classmethod    def __subclasshook__(cls, subclass):        ...

二、__init_subclass__ 详解

1. 基本用法

class Parent:    """父类,定义子类初始化钩子"""    def __init_subclass__(cls, **kwargs):        """        当创建子类时自动调用        cls: 新创建的子类        kwargs: 类定义中的关键字参数        """        print(f"创建子类: {cls.__name__}")        print(f"  参数: {kwargs}")        # 可以添加类属性或修改类        cls.created_by = __name__        # 调用父类的 __init_subclass__        super().__init_subclass__(**kwargs)class Child1(Parent):    """简单的子类"""    passclass Child2(Parent, extra="data", version=1):    """带参数的子类"""    passprint(f"Child1.created_by: {Child1.created_by}")print(f"Child2.created_by: {Child2.created_by}")

2. 注册模式

class PluginRegistry:    """插件注册器"""    plugins = {}  # 存储所有插件    categories = {}  # 按类别存储    def __init_subclass__(cls, **kwargs):        """子类自动注册"""        super().__init_subclass__(**kwargs)        # 获取插件元数据        plugin_name = getattr(cls, 'plugin_name', cls.__name__)        plugin_category = getattr(cls, 'category''default')        # 注册到全局字典        PluginRegistry.plugins[plugin_name] = cls        # 按类别注册        if plugin_category not in PluginRegistry.categories:            PluginRegistry.categories[plugin_category] = []        PluginRegistry.categories[plugin_category].append(cls)        print(f"注册插件: {plugin_name} (类别: {plugin_category})")class BasePlugin(PluginRegistry):    """插件基类"""    plugin_name = None    category = 'default'    def process(self, data):        """处理数据,子类实现"""        raise NotImplementedErrorclass TextPlugin(BasePlugin):    """文本处理插件"""    plugin_name = 'text_processor'    category = 'text'    def process(self, data):        return f"处理文本: {data}"class ImagePlugin(BasePlugin):    """图像处理插件"""    plugin_name = 'image_processor'    category = 'image'    def process(self, data):        return f"处理图像: {data}"class AdvancedTextPlugin(TextPlugin):    """高级文本插件"""    plugin_name = 'advanced_text'    category = 'text'print(f"\n所有插件: {list(PluginRegistry.plugins.keys())}")print(f"文本插件: {[p.__name__ for p in PluginRegistry.categories.get('text', [])]}")print(f"图像插件: {[p.__name__ for p in PluginRegistry.categories.get('image', [])]}")# 使用插件text_plugin = PluginRegistry.plugins['text_processor']()print(text_plugin.process("Hello"))

3. 验证和约束

class ValidatedClass:    """带验证的类"""    def __init_subclass__(cls, **kwargs):        """子类创建时验证"""        super().__init_subclass__(**kwargs)        # 验证必需属性        required_attrs = ['name''version']        for attr in required_attrs:            if not hasattr(cls, attr):                raise TypeError(f"{cls.__name__} 必须定义 {attr} 属性")        # 验证方法        required_methods = ['process''validate']        for method in required_methods:            if not hasattr(cls, method) or not callable(getattr(cls, method)):                raise TypeError(f"{cls.__name__} 必须实现 {method} 方法")        # 版本检查        if cls.version < 1.0:            raise ValueError(f"{cls.__name__} 版本必须 >= 1.0")        print(f"验证通过: {cls.__name__}")class ValidPlugin(ValidatedClass):    """有效的插件"""    name = "test_plugin"    version = 1.5    def process(self, data):        return data    def validate(self, data):        return Truetry:    class InvalidPlugin1(ValidatedClass):        """缺少属性"""        name = "bad_plugin"        # 缺少 versionexcept TypeError as e:    print(f"错误: {e}")try:    class InvalidPlugin2(ValidatedClass):        """缺少方法"""        name = "bad_plugin"        version = 2.0        # 缺少 process 方法except TypeError as e:    print(f"错误: {e}")

4. 混入类和多重继承

class LoggingMixin:    """日志混入类"""    def __init_subclass__(cls, **kwargs):        super().__init_subclass__(**kwargs)        cls.log_enabled = True        print(f"{cls.__name__} 启用了日志")class TimingMixin:    """计时混入类"""    def __init_subclass__(cls, **kwargs):        super().__init_subclass__(**kwargs)        cls.timing_enabled = True        print(f"{cls.__name__} 启用了计时")class ValidationMixin:    """验证混入类"""    def __init_subclass__(cls, **kwargs):        super().__init_subclass__(**kwargs)        cls.validation_enabled = True        print(f"{cls.__name__} 启用了验证")class Service(LoggingMixin, TimingMixin, ValidationMixin):    """服务类,使用多个混入"""    def __init__(self, name):        self.name = name    def process(self):        if hasattr(self'log_enabled'and self.log_enabled:            print(f"[日志] 处理 {self.name}")        if hasattr(self'timing_enabled'and self.timing_enabled:            import time            start = time.time()            # 处理逻辑            time.sleep(0.1)            elapsed = time.time() - start            print(f"[计时] 耗时: {elapsed:.3f}s")        if hasattr(self'validation_enabled'and self.validation_enabled:            print(f"[验证] 验证数据")# 使用service = Service("test")service.process()

三、__subclasshook__ 详解

1. 基本用法

from abc import ABCclass MyInterface:    """自定义接口"""    @classmethod    def __subclasshook__(cls, subclass):        """        检查 subclass 是否是 cls 的子类        返回 True/False/NotImplemented        """        print(f"检查 {subclass.__name__} 是否是 {cls.__name__} 的子类")        # 检查必要的方法        required_methods = ['process''validate']        for method in required_methods:            if not any(hasattr(c, method) for c in subclass.__mro__):                return False        return Trueclass GoodClass:    """实现了所需方法的类"""    def process(self):        pass    def validate(self):        passclass BadClass:    """缺少必要方法的类"""    def process(self):        pass    # 缺少 validateprint(f"GoodClass 是子类? {issubclass(GoodClass, MyInterface)}")print(f"BadClass 是子类? {issubclass(BadClass, MyInterface)}")

2. 实现鸭子类型

class Duck:    """鸭子类"""    @classmethod    def __subclasshook__(cls, subclass):        """任何有 quack 和 swim 方法的类都被认为是鸭子"""        required = ['quack''swim']        for method in required:            if not any(hasattr(c, method) for c in subclass.__mro__):                return False        return Trueclass Mallard:    """野鸭 - 有 quack 和 swim"""    def quack(self):        return "Quack!"    def swim(self):        return "Swimming"class Dog:    """狗 - 只有 swim,没有 quack"""    def swim(self):        return "Dog swimming"class Robot:    """机器人 - 有 quack 和 swim"""    def quack(self):        return "Beep quack"    def swim(self):        return "Robot swimming"print("=== 鸭子类型检查 ===")print(f"Mallard is Duck? {issubclass(Mallard, Duck)}")print(f"Dog is Duck? {issubclass(Dog, Duck)}")print(f"Robot is Duck? {issubclass(Robot, Duck)}")# 实例检查mallard = Mallard()print(f"mallard 是 Duck 实例? {isinstance(mallard, Duck)}")

3. 抽象基类结合使用

from abc import ABC, abstractmethodimport collections.abcclass IterableInterface(ABC):    """可迭代接口"""    @classmethod    def __subclasshook__(cls, subclass):        if cls is IterableInterface:            # 检查是否有 __iter__ 方法            if any("__iter__" in c.__dict__ for c in subclass.__mro__):                return True        return NotImplementedclass SequenceInterface(ABC):    """序列接口"""    @classmethod    def __subclasshook__(cls, subclass):        if cls is SequenceInterface:            # 检查必要的序列方法            methods = ['__len__''__getitem__']            for method in methods:                if not any(method in c.__dict__ for c in subclass.__mro__):                    return False            return True        return NotImplementedclass MyList:    """自定义列表"""    def __init__(self, items):        self._items = items    def __len__(self):        return len(self._items)    def __getitem__(self, index):        return self._items[index]    def __iter__(self):        return iter(self._items)class MyContainer:    """自定义容器"""    def __init__(self, items):        self._items = items    def __iter__(self):        return iter(self._items)print("=== 接口检查 ===")print(f"MyList is Sequence? {issubclass(MyList, SequenceInterface)}")print(f"MyContainer is Sequence? {issubclass(MyContainer, SequenceInterface)}")print(f"MyContainer is Iterable? {issubclass(MyContainer, IterableInterface)}")# 与 collections.abc 对比print(f"\n=== 与 collections.abc 对比 ===")print(f"MyList is Sequence? {issubclass(MyList, collections.abc.Sequence)}")print(f"MyContainer is Iterable? {issubclass(MyContainer, collections.abc.Iterable)}")

四、__class_getitem__ 详解

1. 基本用法(Python 3.7+)

from typing import TypeVar, GenericT = TypeVar('T')class Box:    """泛型盒子"""    def __init__(self, value):        self.value = value    def __class_getitem__(cls, item):        """        支持 Box[T] 语法        item: 类型参数        """        print(f"创建参数化类型: {cls.__name__}[{item}]")        # 创建新的参数化类        class ParametrizedBox(cls):            def __init__(self, value):                if not isinstance(value, item):                    raise TypeError(f"值必须是 {item} 类型")                super().__init__(value)        ParametrizedBox.__name__ = f"{cls.__name__}[{item.__name__}]"        return ParametrizedBox# 使用IntBox = Box[int]StrBox = Box[str]int_box = IntBox(42)str_box = StrBox("hello")print(f"int_box 值: {int_box.value}")print(f"str_box 值: {str_box.value}")try:    invalid_box = IntBox("string")  # 类型错误except TypeError as e:    print(f"错误: {e}")

2. 泛型容器实现

from typing import TypeVar, GenericListimport inspectT = TypeVar('T')K = TypeVar('K')V = TypeVar('V')class GenericList:    """泛型列表"""    _types = {}  # 缓存参数化类型    def __init__(self):        self._items = []    def __class_getitem__(cls, item_type):        """创建参数化版本"""        if item_type in cls._types:            return cls._types[item_type]        # 创建新的列表类        class TypedList(cls):            def __init__(self):                super().__init__()                self.item_type = item_type            def append(self, item):                if not isinstance(item, self.item_type):                    raise TypeError(f"只能添加 {self.item_type.__name__} 类型")                self._items.append(item)            def __getitem__(self, index):                return self._items[index]            def __repr__(self):                return f"{self.__class__.__name__}({self._items})"        TypedList.__name__ = f"{cls.__name__}[{item_type.__name__}]"        cls._types[item_type] = TypedList        return TypedListclass GenericDict:    """泛型字典"""    def __init__(self):        self._items = {}    def __class_getitem__(cls, key_value):        key_type, value_type = key_value        class TypedDict(cls):            def __init__(self):                super().__init__()                self.key_type = key_type                self.value_type = value_type            def __setitem__(self, key, value):                if not isinstance(key, self.key_type):                    raise TypeError(f"键必须是 {self.key_type.__name__} 类型")                if not isinstance(value, self.value_type):                    raise TypeError(f"值必须是 {self.value_type.__name__} 类型")                self._items[key] = value            def __getitem__(self, key):                return self._items[key]            def __repr__(self):                return f"{self.__class__.__name__}({self._items})"        TypedDict.__name__ = f"{cls.__name__}[{key_type.__name__}{value_type.__name__}]"        return TypedDict# 使用泛型列表IntList = GenericList[int]StrList = GenericList[str]int_list = IntList()int_list.append(1)int_list.append(2)int_list.append(3)print(f"IntList: {int_list}")try:    int_list.append("string")  # 类型错误except TypeError as e:    print(f"错误: {e}")# 使用泛型字典StrIntDict = GenericDict[strint]dict1 = StrIntDict()dict1["age"] = 25dict1["score"] = 90print(f"StrIntDict: {dict1}")try:    dict1[123] = 100  # 键类型错误except TypeError as e:    print(f"错误: {e}")

3. 类型检查和运行时信息

from typing import Any, get_args, get_originclass TypedContainer:    """支持运行时类型信息的容器"""    def __init__(self):        self._origin = None        self._args = None    def __class_getitem__(cls, params):        """创建参数化类并保存类型信息"""        if not isinstance(params, tuple):            params = (params,)        # 创建新的参数化类        class Parametrized(cls):            def __init__(self):                super().__init__()                self._origin = cls                self._args = params            @classmethod            def get_origin(cls):                return cls._origin            @classmethod            def get_args(cls):                return cls._args        Parametrized.__name__ = f"{cls.__name__}{params}"        return Parametrized# 使用Vec = TypedContainer[intstr]vec = Vec()print(f"原始类型: {vec._origin.__name__}")print(f"类型参数: {vec._args}")# 使用 typing 模块的函数from typing import get_origin, get_argsclass MyList(TypedContainer[intstr]):    passprint(f"get_origin(MyList): {get_origin(MyList)}")print(f"get_args(MyList): {get_args(MyList)}")

五、总结

1. 方法速查表

 方法
触发时机
主要用途
返回值
__init_subclass__
子类定义时
子类初始化、注册、验证
None
__subclasshook__issubclass()
自定义子类检查
bool
/NotImplemented
__class_getitem__cls[T]
 语法
泛型支持
参数化类

2. 应用场景

 方法
常见应用
__init_subclass__
插件系统、注册模式、验证框架、混入类
__subclasshook__
鸭子类型、接口检查、抽象基类
__class_getitem__
泛型容器、类型提示、运行时类型信息

3. 设计原则

  1. __init_subclass__:用于子类自动注册和验证,避免手动注册

  2. __subclasshook__:实现鸭子类型,让非继承关系的类也能通过检查

  3. __class_getitem__:提供泛型支持,增强类型安全性

4. 常见陷阱

# 陷阱1:忘记调用 super().__init_subclass__class BadChild:    def __init_subclass__(cls):        # 没有调用 super(),可能破坏继承链        pass# 陷阱2:__subclasshook__ 返回错误类型class BadHook:    @classmethod    def __subclasshook__(cls, subclass):        return "True"  # 应该返回 bool 或 NotImplemented# 陷阱3:__class_getitem__ 不返回类class BadGeneric:    def __class_getitem__(cls, item):        return item  # 应该返回类# 陷阱4:在 __init_subclass__ 中修改子类导致循环class Circular:    def __init_subclass__(cls):        # 创建新的子类可能导致无限循环        class NewSubclass(cls):            pass

5. 最佳实践

class BestPractices:    """最佳实践示例"""    # 1. 总是调用 super().__init_subclass__    def __init_subclass__(cls, **kwargs):        super().__init_subclass__(**kwargs)        # 自定义逻辑    # 2. __subclasshook__ 返回 NotImplemented 表示不处理    @classmethod    def __subclasshook__(cls, subclass):        if cls is BestPractices:            # 只处理当前类            pass        return NotImplemented    # 3. __class_getitem__ 缓存参数化类    _cache = {}    def __class_getitem__(cls, item):        if item in cls._cache:            return cls._cache[item]        class Parametrized(cls):            pass        cls._cache[item] = Parametrized        return Parametrized

这些类相关的特殊方法提供了强大的元编程能力,让我们能够控制类的创建、检查和泛型行为,是构建框架和库的重要工具。

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 13:02:19 HTTP/2.0 GET : https://f.mffb.com.cn/a/482921.html
  2. 运行时间 : 0.122384s [ 吞吐率:8.17req/s ] 内存消耗:4,451.25kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=6563cf1ce6a046beeeda02d0cc7f7968
  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.000416s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000517s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000269s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.001436s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000585s ]
  6. SELECT * FROM `set` [ RunTime:0.002077s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000582s ]
  8. SELECT * FROM `article` WHERE `id` = 482921 LIMIT 1 [ RunTime:0.002264s ]
  9. UPDATE `article` SET `lasttime` = 1774587739 WHERE `id` = 482921 [ RunTime:0.004645s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.001392s ]
  11. SELECT * FROM `article` WHERE `id` < 482921 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.006211s ]
  12. SELECT * FROM `article` WHERE `id` > 482921 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.004901s ]
  13. SELECT * FROM `article` WHERE `id` < 482921 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.005439s ]
  14. SELECT * FROM `article` WHERE `id` < 482921 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.014448s ]
  15. SELECT * FROM `article` WHERE `id` < 482921 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001124s ]
0.123913s