当前位置:首页>python>Python学习--对象表示方法详解

Python学习--对象表示方法详解

  • 2026-03-09 15:53:44
Python学习--对象表示方法详解

一、四种表示方法对比

 方法
调用时机
目的
返回值要求
典型用途
__str__str()
print()format() 默认
用户友好的字符串
字符串
显示给最终用户
__repr__repr()
, 交互式解释器, 调试
开发者友好的字符串
字符串(应能用于eval()
调试、日志、开发
__format__format()
, f-string, str.format()
格式化输出
字符串
自定义格式化
__bytes__bytes()
字节表示
bytes
对象
序列化、网络传输

二、__str__ 方法:用户友好表示

1. 基本语法

class Person:    def __init__(self, name, age):        self.name = name        self.age = age    def __str__(self):        """返回用户友好的字符串表示"""        return f"Person: {self.name}{self.age} years old"    # 如果没有定义 __str__,Python会使用 __repr__ 代替# 使用p = Person("Alice"25)print(p)            # 隐式调用 __str__print(str(p))       # 显式调用 __str__

2. 实际应用示例

class Product:    """产品类 - 展示给用户的信息"""    def __init__(self, id, name, price, category):        self.id = id        self.name = name        self.price = price        self.category = category    def __str__(self):        """用户看到的格式:清晰、易读"""        return f"{self.name} - ¥{self.price:.2f} ({self.category})"    def display_details(self):        """更详细的显示方法"""        return f"""产品详情:-----------名称:{self.name}价格:¥{self.price:.2f}分类:{self.category}编号:{self.id}-----------"""# 使用product = Product("P001""Python编程从入门到精通"89.90"图书")print(product)  # Python编程从入门到精通 - ¥89.90 (图书)print(product.display_details())

三、__repr__ 方法:开发者友好表示

1. 基本语法和原则

class Point:    def __init__(self, x, y):        self.x = x        self.y = y    def __repr__(self):        """        原则:应该返回一个字符串,能够用于重新创建对象        格式通常为:ClassName(arg1, arg2, ...)        """        return f"Point({self.x}{self.y})"    # __repr__ 应该尽量详细,包含重建对象所需的所有信息# 使用p = Point(34)print(repr(p))      # Point(3, 4)# 理论上可以这样重建对象(如果实现正确)# eval(repr(p))  # 创建一个新的Point对象

2. 实际应用:可重建的表示

from datetime import datetimeimport jsonclass Order:    def __init__(self, order_id, customer, items, order_date=None):        self.order_id = order_id        self.customer = customer        self.items = items        self.order_date = order_date or datetime.now()    def __repr__(self):        """详细的、可重建的表示"""        return (            f"Order(order_id={repr(self.order_id)}, "            f"customer={repr(self.customer)}, "            f"items={repr(self.items)}, "            f"order_date={repr(self.order_date)})"        )    def __str__(self):        """用户友好的表示"""        return f"订单 #{self.order_id} - {self.customer}"# 使用order = Order(    order_id="ORD20231215001",    customer="张三",    items=["Python书籍""鼠标""键盘"],    order_date=datetime(202312151030))print(str(order))   # 订单 #ORD20231215001 - 张三print(repr(order))  # Order(order_id='ORD20231215001', customer='张三', items=['Python书籍', '鼠标', '键盘'], order_date=datetime.datetime(2023, 12, 15, 10, 30))# 在调试时特别有用import pprintpprint.pprint(repr(order))

四、__format__ 方法:格式化控制

1. 基本语法

class Temperature:    def __init__(self, celsius):        self.celsius = celsius    @property    def fahrenheit(self):        return self.celsius * 9/5 + 32    @property    def kelvin(self):        return self.celsius + 273.15    def __format__(self, format_spec):        """        format_spec: 格式化说明符,如 'c', 'f', 'k', '.1f' 等        """        if not format_spec:            # 默认格式:摄氏度,保留1位小数            return f"{self.celsius:.1f}°C"        if format_spec == 'c':            return f"{self.celsius:.1f}°C"        elif format_spec == 'f':            return f"{self.fahrenheit:.1f}°F"        elif format_spec == 'k':            return f"{self.kelvin:.1f}K"        elif format_spec.startswith('c'):            # 自定义精度:c.2 表示摄氏度保留2位小数            try:                precision = int(format_spec[1:])                return f"{self.celsius:.{precision}f}°C"            except ValueError:                return f"{self.celsius:.1f}°C"        else:            # 使用Python的默认格式化            return format(self.celsius, format_spec)# 使用temp = Temperature(25.5)print(f"默认格式: {temp}")           # 25.5°Cprint(f"摄氏度: {temp:c}")           # 25.5°Cprint(f"华氏度: {temp:f}")           # 77.9°Fprint(f"开氏度: {temp:k}")           # 298.7Kprint(f"摄氏度(2位): {temp:c.2}")    # 25.50°Cprint(f"科学计数: {temp:e}")         # 2.550000e+01°C

2. 复杂格式化示例

from datetime import datetime, timedeltaclass Timer:    def __init__(self, seconds):        self.seconds = seconds    def __format__(self, format_spec):        """        支持多种时间格式:        - 's': 只显示秒        - 'm': 分:秒        - 'h': 时:分:秒        - 'full': 完整的时间分解        """        if not format_spec:            format_spec = 'h'  # 默认格式        if format_spec == 's':            return f"{self.seconds}秒"        elif format_spec == 'm':            minutes = self.seconds // 60            seconds = self.seconds % 60            return f"{minutes:02d}:{seconds:02d}"        elif format_spec == 'h':            hours = self.seconds // 3600            minutes = (self.seconds % 3600) // 60            seconds = self.seconds % 60            return f"{hours:02d}:{minutes:02d}:{seconds:02d}"        elif format_spec == 'full':            days = self.seconds // 86400            hours = (self.seconds % 86400) // 3600            minutes = (self.seconds % 3600) // 60            seconds = self.seconds % 60            parts = []            if days > 0:                parts.append(f"{days}天")            if hours > 0 or parts:                parts.append(f"{hours}小时")            if minutes > 0 or parts:                parts.append(f"{minutes}分")            parts.append(f"{seconds}秒")            return " ".join(parts)        else:            # 默认:按秒格式化            return format(self.seconds, format_spec)# 使用timer = Timer(3665)  # 1小时1分钟5秒print(f"默认格式: {timer}")        # 01:01:05print(f"秒格式: {timer:s}")        # 3665秒print(f"分:秒格式: {timer:m}")     # 61:05print(f"时:分:秒格式: {timer:h}")  # 01:01:05print(f"完整格式: {timer:full}")   # 1小时1分5秒print(f"科学计数: {timer:e}")      # 3.665000e+03

五、__bytes__ 方法:字节表示

1. 基本语法

class Serializable:    def __init__(self, data):        self.data = data    def __bytes__(self):        """返回对象的字节表示"""        # 通常需要序列化为字节        import pickle        return pickle.dumps(self.data)    @classmethod    def from_bytes(cls, byte_data):        """从字节重建对象"""        import pickle        data = pickle.loads(byte_data)        return cls(data)# 使用obj = Serializable({"name""Alice""age"25})byte_repr = bytes(obj)print(f"字节表示: {byte_repr}")print(f"长度: {len(byte_repr)} 字节")# 重建对象new_obj = Serializable.from_bytes(byte_repr)print(f"重建的数据: {new_obj.data}")

2. 实际应用:自定义二进制协议

import structfrom typing import Listclass Vector3D:    """三维向量,支持二进制序列化"""    def __init__(self, x: float, y: float, z: float):        self.x = x        self.y = y        self.z = z    def __bytes__(self):        """        使用 struct 打包为二进制        'fff' 表示三个浮点数(4字节每个)        """        return struct.pack('fff'self.x, self.y, self.z)    def __str__(self):        return f"Vector3D({self.x}{self.y}{self.z})"    def __repr__(self):        return f"Vector3D({self.x}{self.y}{self.z})"    @classmethod    def from_bytes(cls, data: bytes):        """从字节重建向量"""        x, y, z = struct.unpack('fff', data)        return cls(x, y, z)class Mesh:    """网格,包含多个顶点"""    def __init__(self, name: str, vertices: List[Vector3D]):        self.name = name        self.vertices = vertices    def __bytes__(self):        """        二进制格式:        - 4字节:名称长度        - 名称(UTF-8编码)        - 4字节:顶点数量        - 每个顶点:12字节(3个float)        """        # 编码名称        name_bytes = self.name.encode('utf-8')        name_len = len(name_bytes)        # 打包头部信息        header = struct.pack(f'I{name_len}sI'                           name_len, name_bytes, len(self.vertices))        # 打包所有顶点        vertices_data = b''.join(bytes(v) for v in self.vertices)        return header + vertices_data    @classmethod    def from_bytes(cls, data: bytes):        """从字节重建网格"""        # 解析头部        name_len = struct.unpack('I', data[:4])[0]        name = struct.unpack(f'{name_len}s', data[4:4+name_len])[0].decode('utf-8')        vertex_count = struct.unpack('I', data[4+name_len:8+name_len])[0]        # 解析顶点        vertices = []        offset = 8 + name_len        for _ in range(vertex_count):            vertex_data = data[offset:offset+12]            vertices.append(Vector3D.from_bytes(vertex_data))            offset += 12        return cls(name, vertices)    def __str__(self):        return f"Mesh '{self.name}' with {len(self.vertices)} vertices"    def __repr__(self):        return f"Mesh(name={repr(self.name)}, vertices={self.vertices})"# 使用示例print("=== 单个向量 ===")v1 = Vector3D(1.02.03.0)v1_bytes = bytes(v1)print(f"向量: {v1}")print(f"字节表示: {v1_bytes}")print(f"长度: {len(v1_bytes)} 字节")# 重建v1_reconstructed = Vector3D.from_bytes(v1_bytes)print(f"重建的向量: {v1_reconstructed}")print(f"是否相等: {v1.x == v1_reconstructed.x}")print("\n=== 网格对象 ===")vertices = [    Vector3D(000),    Vector3D(100),    Vector3D(010),    Vector3D(110)]mesh = Mesh("triangle_mesh", vertices)mesh_bytes = bytes(mesh)print(f"网格: {mesh}")print(f"网格字节长度: {len(mesh_bytes)} 字节")# 重建网格mesh_reconstructed = Mesh.from_bytes(mesh_bytes)print(f"重建的网格: {mesh_reconstructed}")

六、综合示例:完整的数据类

from dataclasses import dataclass, asdictfrom datetime import datetimeimport jsonimport structfrom typing import AnyDict@dataclassclass DataRecord:    """数据记录类,支持多种表示形式"""    idint    name: str    value: float    timestamp: datetime    metadata: Dict[strAny] = None    def __post_init__(self):        if self.metadata is None:            self.metadata = {}    def __str__(self) -> str:        """用户友好表示"""        return (f"记录 #{self.id}{self.name} = {self.value:.2f} "                f"({self.timestamp.strftime('%Y-%m-%d %H:%M:%S')})")    def __repr__(self) -> str:        """开发者表示,可重建"""        return (f"DataRecord(id={self.id}, name={repr(self.name)}, "                f"value={self.value}, timestamp={repr(self.timestamp)}, "                f"metadata={self.metadata})")    def __format__(self, format_spec: str) -> str:        """格式化表示"""        if not format_spec:            return str(self)        format_spec = format_spec.lower()        if format_spec == 'json':            return json.dumps(self.to_dict(), ensure_ascii=False, indent=2)        elif format_spec == 'csv':            return f"{self.id},{self.name},{self.value},{self.timestamp.isoformat()}"        elif format_spec == 'table':            return (f"| {self.id:4d} | {self.name:20s} | "                    f"{self.value:8.2f} | {self.timestamp:%Y-%m-%d %H:%M} |")        elif format_spec.startswith('value'):            # 只显示值,可指定精度:value.3            try:                if '.' in format_spec:                    precision = int(format_spec.split('.')[1])                    return f"{self.value:.{precision}f}"            except (ValueError, IndexError):                pass            return f"{self.value:.2f}"        else:            # 尝试应用格式说明符到值            try:                return format(self.value, format_spec)            except (ValueError, TypeError):                return str(self)    def __bytes__(self) -> bytes:        """二进制表示"""        # 序列化字符串字段        name_bytes = self.name.encode('utf-8')        name_len = len(name_bytes)        # 序列化metadata        metadata_json = json.dumps(self.metadata).encode('utf-8')        metadata_len = len(metadata_json)        # 序列化时间戳(Unix时间戳,8字节double)        timestamp_float = self.timestamp.timestamp()        # 打包所有数据        # 格式:id(4B) + 名称长度(2B) + 名称 + 值(8B) + 时间戳(8B) + metadata长度(4B) + metadata        return struct.pack(f'I H {name_len}s d d I {metadata_len}s',                          self.id,                          name_len,                          name_bytes,                          self.value,                          timestamp_float,                          metadata_len,                          metadata_json)    @classmethod    def from_bytes(cls, data: bytes) -> 'DataRecord':        """从字节重建"""        # 解析id和名称长度        id_val = struct.unpack('I', data[:4])[0]        name_len = struct.unpack('H', data[4:6])[0]        # 解析名称        name = struct.unpack(f'{name_len}s', data[6:6+name_len])[0].decode('utf-8')        # 解析值和时间戳        offset = 6 + name_len        value = struct.unpack('d', data[offset:offset+8])[0]        timestamp_float = struct.unpack('d', data[offset+8:offset+16])[0]        timestamp = datetime.fromtimestamp(timestamp_float)        # 解析metadata        metadata_len = struct.unpack('I', data[offset+16:offset+20])[0]        metadata_json = struct.unpack(f'{metadata_len}s',                                    data[offset+20:offset+20+metadata_len])[0]        metadata = json.loads(metadata_json.decode('utf-8'))        return cls(id_val, name, value, timestamp, metadata)    def to_dict(self) -> dict:        """转换为字典"""        return {            'id'self.id,            'name'self.name,            'value'self.value,            'timestamp'self.timestamp.isoformat(),            'metadata'self.metadata        }    @classmethod    def from_dict(cls, data: dict) -> 'DataRecord':        """从字典重建"""        return cls(            id=data['id'],            name=data['name'],            value=data['value'],            timestamp=datetime.fromisoformat(data['timestamp']),            metadata=data.get('metadata', {})        )# 使用示例def demonstrate_all_representations():    print("=== DataRecord 所有表示方法演示 ===\n")    # 创建记录    record = DataRecord(        id=1001,        name="温度传感器",        value=25.56789,        timestamp=datetime.now(),        metadata={"unit""°C""location""实验室""calibrated"True}    )    print("1. __str__ (用户友好):")    print(f"   {record}")    print()    print("2. __repr__ (开发者):")    print(f"   {repr(record)}")    print()    print("3. __format__ (各种格式):")    print(f"   默认: {record}")    print(f"   JSON: {record:json}")    print(f"   CSV: {record:csv}")    print(f"   表格: {record:table}")    print(f"   只显示值: {record:value}")    print(f"   值(3位小数): {record:value.3}")    print(f"   科学计数: {record:e}")    print()    print("4. __bytes__ (二进制):")    record_bytes = bytes(record)    print(f"   字节长度: {len(record_bytes)}")    print(f"   前50字节: {record_bytes[:50]}...")    print()    print("5. 从字节重建:")    reconstructed = DataRecord.from_bytes(record_bytes)    print(f"   重建的记录: {reconstructed}")    print(f"   是否相等: {record == reconstructed}")    print()    print("6. f-string 格式化:")    print(f"   记录: {record}")    print(f"   JSON格式: {record:json}")    print(f"   表格格式: {record:table}")    print("\n7. 在列表中使用:")    records = [        DataRecord(1001"温度"25.5, datetime.now()),        DataRecord(1002"湿度"65.2, datetime.now()),        DataRecord(1003"压力"101.3, datetime.now())    ]    print("   表格视图:")    print("   " + "-" * 50)    print("   | ID   | 名称               | 值       | 时间              |")    print("   " + "-" * 50)    for r in records:        print(f"   {r:table}")    print("   " + "-" * 50)demonstrate_all_representations()

七、最佳实践总结

1. __str__ 设计原则:

2. __repr__ 设计原则:

  • 目标用户:开发者

  • 内容:详细、完整、可重建

  • 格式:通常为 ClassName(arg1, arg2, ...)

  • 原则eval(repr(obj)) == obj(理想情况)

  • 示例"Order(id=12345, customer='张三', total=199.99)"

3. __format__ 设计原则:

  • 目标用户:需要格式化输出的用户

  • 内容:支持多种格式和样式

  • 格式:根据 format_spec 动态变化

  • 兼容:应该处理未知的格式说明符

  • 示例:支持 f"{obj:json}"f"{obj:.2f}" 等

4. __bytes__ 设计原则:

  • 目标用户:需要二进制表示的场景

  • 内容:高效、紧凑、可逆

  • 格式:通常使用 struct 模块

  • 注意:考虑大小端和版本兼容性

  • 示例:网络传输、文件存储、二进制协议

5. 实现建议:

  1. 优先实现 __repr__:Python 在没有 __str__ 时会使用 __repr__

  2. 保持一致性__repr__ 应该包含重建对象所需的所有信息

  3. 提供默认处理:在 __format__ 中处理空的或未知的格式说明符

  4. 考虑性能__bytes__ 可能被频繁调用,应保持高效

  5. 支持双向转换:实现 __bytes__ 时,最好也提供对应的类方法从字节重建

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 19:56:51 HTTP/2.0 GET : https://f.mffb.com.cn/a/478170.html
  2. 运行时间 : 0.160088s [ 吞吐率:6.25req/s ] 内存消耗:4,846.48kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=cdc493eebd1a0d6c5b679136a054d4b2
  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.001097s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001064s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000332s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000278s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000476s ]
  6. SELECT * FROM `set` [ RunTime:0.000195s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000513s ]
  8. SELECT * FROM `article` WHERE `id` = 478170 LIMIT 1 [ RunTime:0.000497s ]
  9. UPDATE `article` SET `lasttime` = 1774612611 WHERE `id` = 478170 [ RunTime:0.005614s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000289s ]
  11. SELECT * FROM `article` WHERE `id` < 478170 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000564s ]
  12. SELECT * FROM `article` WHERE `id` > 478170 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000370s ]
  13. SELECT * FROM `article` WHERE `id` < 478170 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000637s ]
  14. SELECT * FROM `article` WHERE `id` < 478170 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000924s ]
  15. SELECT * FROM `article` WHERE `id` < 478170 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001998s ]
0.161645s