当前位置:首页>python>Python学习--属性访问方法详解

Python学习--属性访问方法详解

  • 2026-03-10 14:12:56
Python学习--属性访问方法详解

一、属性访问方法概述

1. 四种核心方法

 方法
触发时机
默认行为
用途
__getattr__
访问不存在的属性时
抛出 AttributeError
动态属性、属性代理
__getattribute__
访问任何属性时(包括存在的)
获取属性值
属性访问拦截、权限控制
__setattr__
设置属性时
设置属性值
属性验证、日志记录
__delattr__
删除属性时
删除属性
清理操作、权限控制

2. 方法调用顺序

属性访问(obj.name)        ↓__getattribute__(总是调用)        ↓如果属性存在 → 返回属性值如果属性不存在 → 调用 __getattr__        ↓如果 __getattr__ 不存在 → 抛出 AttributeError

二、__getattr__ 详解

1. 基本用法

class DynamicAttributes:    def __init__(self):        self.existing_attr = "我是存在的属性"        self._data = {"name""Alice""age"25}    def __getattr__(self, name):        """        访问不存在的属性时调用        name: 要访问的属性名        应该返回属性值或抛出 AttributeError        """        print(f"__getattr__ 被调用,访问不存在的属性: {name}")        # 尝试从 _data 字典中获取        if name in self._data:            return self._data[name]        # 动态创建方法        if name.startswith('get_'):            attr_name = name[4:]            def getter():                return self._data.get(attr_name, "未知")            return getter        # 属性不存在,抛出异常        raise AttributeError(f"'{type(self).__name__}' 对象没有属性 '{name}'")# 使用obj = DynamicAttributes()print(obj.existing_attr)  # 存在属性,不会调用 __getattr__print(obj.name)          # 不存在属性,调用 __getattr__,返回 "Alice"print(obj.age)           # 不存在属性,调用 __getattr__,返回 25# 动态方法get_name = obj.get_nameprint(get_name())        # 调用动态创建的方法,返回 "Alice"try:    print(obj.nonexistent)except AttributeError as e:    print(f"错误: {e}")

2. 实际应用:属性代理

class ConfigProxy:    """配置文件代理 - 从配置文件动态加载属性"""    def __init__(self, config_file=None):        self.config_file = config_file        self._loaded_config = {}    def __getattr__(self, name):        """从配置文件加载配置项"""        print(f"尝试获取配置项: {name}")        # 如果是特殊属性,交给默认处理        if name.startswith('_'):            return super().__getattr__(name)        # 尝试从已加载的配置中获取        if name in self._loaded_config:            return self._loaded_config[name]        # 模拟从文件加载配置        config_value = self._load_from_file(name)        if config_value is not None:            self._loaded_config[name] = config_value            return config_value        # 返回默认值        return None    def _load_from_file(self, name):        """模拟从配置文件加载"""        # 这里应该是实际的文件读取逻辑        mock_config = {            'database_url''mysql://localhost:3306/mydb',            'debug_mode'True,            'max_connections'100,            'timeout'30        }        return mock_config.get(name)# 使用config = ConfigProxy('config.ini')# 访问配置项(第一次会加载)print(config.database_url)  # mysql://localhost:3306/mydbprint(config.debug_mode)    # True# 第二次访问直接使用缓存的值print(config.database_url)  # 直接从 _loaded_config 返回# 不存在的配置返回 Noneprint(config.nonexistent)   # None

三、__getattribute__ 详解

1. 基本用法和注意事项

class AttributeInspector:    def __init__(self):        self.name = "Alice"        self.age = 25    def __getattribute__(self, name):        """        访问任何属性时都会调用        注意:必须非常小心避免无限递归        """        print(f"正在访问属性: {name}")        # 使用 super() 获取属性(避免递归)        try:            value = super().__getattribute__(name)        except AttributeError:            value = None        print(f"属性 {name} 的值是: {value}")        return value    def __getattr__(self, name):        """当属性不存在时调用"""        return f"默认值({name})"# 使用obj = AttributeInspector()print(obj.name)      # 访问存在的属性print(obj.age)       # 访问存在的属性print(obj.city)      # 访问不存在的属性

2. 避免无限递归

class SafeAttributeAccess:    def __init__(self):        self.data = {"a"1"b"2}    def __getattribute__(self, name):        """安全的属性访问实现"""        # 危险写法(会引起无限递归):        # return self.__dict__[name]  # 会再次调用 __getattribute__        # 正确写法1:使用 object.__getattribute__        # return object.__getattribute__(self, name)        # 正确写法2:使用 super()        if name == 'special':            return "特殊处理"        return super().__getattribute__(name)    def __setattr__(self, name, value):        """安全的属性设置"""        # 危险写法:        # self.name = value  # 会再次调用 __setattr__        # 正确写法:        super().__setattr__(name, value)    def __getattr__(self, name):        """访问不存在属性时的备用方案"""        if name.startswith('get_'):            key = name[4:]            return lambdaself.data.get(key)        return super().__getattr__(name)# 使用obj = SafeAttributeAccess()print(obj.a)  # 不存在,但不会无限递归

四、__setattr__ 详解

1. 属性验证

class ValidatedPerson:    def __init__(self, name, age, email):        # 直接调用 __setattr__ 进行初始化        self.name = name        self.age = age        self.email = email    def __setattr__(self, name, value):        """设置属性时进行验证"""        print(f"验证属性: {name} = {value}")        if name == 'name':            if not isinstance(value, str):                raise TypeError("姓名必须是字符串")            if len(value) < 2:                raise ValueError("姓名长度至少为2个字符")        elif name == 'age':            if not isinstance(value, (intfloat)):                raise TypeError("年龄必须是数字")            if not (0 <= value <= 150):                raise ValueError("年龄必须在0-150之间")        elif name == 'email':            if not isinstance(value, str):                raise TypeError("邮箱必须是字符串")            if '@' not in value:                raise ValueError("邮箱格式不正确")        # 调用父类的 __setattr__ 实际设置属性        super().__setattr__(name, value)# 使用try:    p = ValidatedPerson("A"25"test@example.com")  # 姓名太短except ValueError as e:    print(f"创建失败: {e}")try:    p = ValidatedPerson("Alice"200"test@example.com")  # 年龄太大except ValueError as e:    print(f"创建失败: {e}")try:    p = ValidatedPerson("Alice"25"invalid-email")  # 邮箱无效except ValueError as e:    print(f"创建失败: {e}")# 正确创建p = ValidatedPerson("Alice"25"alice@example.com")print(f"成功创建: {p.name}{p.age}{p.email}")

2. 属性类型转换和规范化

class NormalizedAttributes:    def __setattr__(self, name, value):        """设置属性时自动转换和规范化"""        # 类型转换规则        type_rules = {            'age'int,            'price'float,            'name'str,            'tags'lambda x: x if isinstance(x, listelse [x],            'active'bool        }        # 名称规范化        name = name.lower().strip()        # 应用类型转换        if name in type_rules:            try:                converter = type_rules[name]                value = converter(value)            except (ValueError, TypeError):                pass        # 字符串规范化        if isinstance(value, str):            value = value.strip()            if name in ('name''title''description'):                value = value.capitalize()        # 数字范围限制        if name == 'age':            value = max(0min(150, value))        elif name == 'price':            value = max(0, value)        # 设置属性        super().__setattr__(name, value)# 使用obj = NormalizedAttributes()# 自动转换类型obj.age = "25"           # 自动转换为 intobj.price = "19.99"      # 自动转换为 floatobj.active = 1           # 自动转换为 bool (True)obj.tags = "python"      # 自动转换为 ["python"]print(f"age: {obj.age} ({type(obj.age).__name__})")print(f"price: {obj.price} ({type(obj.price).__name__})")print(f"active: {obj.active} ({type(obj.active).__name__})")print(f"tags: {obj.tags}")# 自动规范化obj.NAME = "  alice  "   # 自动转小写并去除空格obj.title = "python programming"  # 自动首字母大写print(f"name: {obj.name}")print(f"title: {obj.title}")# 范围限制obj.age = 200            # 自动限制为150obj.price = -10          # 自动限制为0print(f"age: {obj.age}")print(f"price: {obj.price}")

五、__delattr__ 详解

1. 基本用法和权限控制

class ProtectedObject:    def __init__(self):        self.public = "公开属性"        self._protected = "受保护属性"        self.__private = "私有属性"  # 会被名称修饰        self._critical = "关键属性"        self.deletable = "可删除属性"    def __delattr__(self, name):        """删除属性时的控制"""        print(f"尝试删除属性: {name}")        # 禁止删除某些属性        if name == '_critical':            raise AttributeError(f"禁止删除关键属性 '{name}'")        if name.startswith('_'):            # 需要确认            confirm = input(f"确定要删除受保护属性 '{name}'? (y/n): ")            if confirm.lower() != 'y':                print("取消删除")                return        # 执行实际的删除操作        super().__delattr__(name)        print(f"属性 '{name}' 已删除")# 使用obj = ProtectedObject()# 删除普通属性del obj.deletable# 尝试删除关键属性try:    del obj._criticalexcept AttributeError as e:    print(f"错误: {e}")# 删除受保护属性(需要确认)# del obj._protected  # 会提示确认

2. 清理资源

import tempfileimport osclass TempFileManager:    """临时文件管理器"""    def __init__(self):        self.temp_files = []        self.data = {}        self._create_temp_files()    def _create_temp_files(self):        """创建临时文件"""        for i in range(3):            fd, path = tempfile.mkstemp()            os.close(fd)            self.temp_files.append(path)            self.data[f"file{i}"] = path        print(f"创建了 {len(self.temp_files)} 个临时文件")    def __delattr__(self, name):        """删除属性时清理相关资源"""        print(f"清理属性 '{name}' 的资源")        if name in self.data:            # 删除对应的临时文件            file_path = self.data[name]            if os.path.exists(file_path):                os.remove(file_path)                print(f"已删除临时文件: {file_path}")        # 执行实际的删除操作        super().__delattr__(name)    def cleanup_all(self):        """清理所有资源"""        for name in list(self.data.keys()):            delattr(self, name)        # 删除剩余的临时文件        for file_path in self.temp_files:            if os.path.exists(file_path):                os.remove(file_path)        print("所有资源已清理")# 使用manager = TempFileManager()# 删除单个属性(自动清理文件)del manager.file0# 或者批量清理manager.cleanup_all()

六、__dir__ 详解

1. 基本用法

class CustomDir:    def __init__(self):        self.name = "Alice"        self.age = 25        self._secret = "秘密"    def __dir__(self):        """控制 dir() 的输出"""        print("__dir__ 被调用")        # 获取默认的属性和方法列表        default_dir = super().__dir__()        # 可以添加自定义的属性        custom_attributes = ['dynamic_attr1''dynamic_attr2']        # 也可以过滤掉某些属性        filtered = [attr for attr in default_dir                    if not attr.startswith('_'or attr == '__init__']        # 合并并返回        return sorted(set(filtered + custom_attributes))    def __getattr__(self, name):        """支持动态属性"""        if name.startswith('dynamic_'):            return f"动态属性 {name} 的值"# 使用obj = CustomDir()print(dir(obj))print([attr for attr in dir(obj) if not attr.startswith('__')])

2. 实际应用:API文档生成

class APIClient:    """API客户端 - 动态生成方法"""    def __init__(self, base_url):        self.base_url = base_url        self._available_endpoints = {            'users': ['get''post''put''delete'],            'posts': ['get''post'],            'comments': ['get''post''put']        }    def __getattr__(self, name):        """动态创建API方法"""        if '_' in name:            resource, method = name.split('_'1)            if resource in self._available_endpoints:                if method in self._available_endpoints[resource]:                    return lambda **kwargs: self._call_api(resource, method, **kwargs)        raise AttributeError(f"未知的API方法: {name}")    def __dir__(self):        """生成动态的API方法列表"""        # 获取基本属性和方法        base_dir = super().__dir__()        # 生成动态方法名        dynamic_methods = []        for resource, methods in self._available_endpoints.items():            for method in methods:                dynamic_methods.append(f"{resource}_{method}")        # 返回完整的列表        return sorted(set(base_dir + dynamic_methods))    def _call_api(self, resource, method, **params):        """模拟API调用"""        return f"调用API: {method.upper()}{self.base_url}/{resource} 参数={params}"# 使用api = APIClient("https://api.example.com")# 查看可用方法print("可用的API方法:")for method in dir(api):    if '_' in method and not method.startswith('_'):        print(f"  {method}")# 调用动态方法print(api.users_get(id=1))print(api.posts_post(title="新文章"))print(api.comments_put(id=5, content="新评论"))

七、最佳实践和注意事项

1. 方法选择指南

 需求
推荐方法
说明
 动态属性
__getattr__
只在属性不存在时调用,性能好
 访问控制
__getattribute__
拦截所有访问,但要注意性能
 属性验证
__setattr__
设置时验证,避免无效数据
 资源清理
__delattr__
删除时清理相关资源
 智能提示
__dir__
提供更好的开发体验

2. 性能考虑

import timeclass PerformanceTest:    def __init__(self):        self._data = {}        self.normal_attr = "正常属性"    def __getattr__(self, name):        if name in self._data:            return self._data[name]        raise AttributeError    def __getattribute__(self, name):        # 会减慢所有属性访问        return super().__getattribute__(name)# 性能对比obj = PerformanceTest()# 正常属性访问start = time.perf_counter()for _ in range(1000000):    x = obj.normal_attrnormal_time = time.perf_counter() - start# 动态属性访问obj._data['dynamic'] = "动态属性"start = time.perf_counter()for _ in range(1000000):    x = obj.dynamicdynamic_time = time.perf_counter() - startprint(f"正常属性: {normal_time:.4f}秒")print(f"动态属性: {dynamic_time:.4f}秒")print(f"动态属性比正常属性慢 {dynamic_time/normal_time:.1f} 倍")

3. 安全注意事项

class SafeImplementation:    def __init__(self):        # 使用双下划线避免无限递归        self.__dict__['_data'] = {}    def __getattr__(self, name):        # 安全:只处理不存在的属性        if name in self.__dict__['_data']:            return self.__dict__['_data'][name]        raise AttributeError    def __setattr__(self, name, value):        # 安全:区分内部属性        if name.startswith('_'):            self.__dict__[name] = value        else:            self.__dict__['_data'][name] = value    def __getattribute__(self, name):        # 安全:避免递归,使用 super()        if name == '_data':            return super().__getattribute__(name)        return super().__getattribute__(name)

4. 总结要点

  1. 性能意识__getattribute__ 会影响所有属性访问

  2. 避免递归:始终使用 super() 调用父类方法

  3. 返回NotImplemented:在比较方法中返回 NotImplemented

  4. 文档完善:为动态属性提供清晰的文档

  5. 一致性:确保所有属性访问行为一致

  6. 异常处理:适当抛出 AttributeError

  7. 安全性:考虑访问控制和权限验证

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 21:44:59 HTTP/2.0 GET : https://f.mffb.com.cn/a/478912.html
  2. 运行时间 : 0.135299s [ 吞吐率:7.39req/s ] 内存消耗:4,541.91kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=9b740f400a80ae88429ad3fb6feccdf9
  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.000688s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000935s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000369s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000335s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000639s ]
  6. SELECT * FROM `set` [ RunTime:0.000277s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000735s ]
  8. SELECT * FROM `article` WHERE `id` = 478912 LIMIT 1 [ RunTime:0.006493s ]
  9. UPDATE `article` SET `lasttime` = 1774619100 WHERE `id` = 478912 [ RunTime:0.004028s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000342s ]
  11. SELECT * FROM `article` WHERE `id` < 478912 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000596s ]
  12. SELECT * FROM `article` WHERE `id` > 478912 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000429s ]
  13. SELECT * FROM `article` WHERE `id` < 478912 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000805s ]
  14. SELECT * FROM `article` WHERE `id` < 478912 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000670s ]
  15. SELECT * FROM `article` WHERE `id` < 478912 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002999s ]
0.136940s