当前位置:首页>python>Python零基础入门(三):面向对象编程基础

Python零基础入门(三):面向对象编程基础

  • 2026-07-03 02:16:34
Python零基础入门(三):面向对象编程基础

前言

前两篇我们分别学习了环境搭建与数据类型以及运算符与条件判断。有了这些基础,现在可以进入 Python 的核心编程范式——面向对象编程(Object-Oriented Programming,OOP) 。

面向对象听起来有点抽象,但其实它就在我们身边。我们每天都在用 list.append()str.upper()dict.keys()——这些都是对象的方法。本篇的目标就是让你从"会用对象"升级为"会定义自己的类"。


一、为什么需要面向对象?

先看一个场景:假设你要管理一个学生成绩系统,每个学生有姓名、年龄、成绩,还有一些操作(计算等级、打印信息)。用之前学的字典和列表也能做:

student1 = {"name": "小明", "age": 20, "score": 85}student2 = {"name": "小红", "age": 21, "score": 92}def get_grade(student):    score = student["score"]    if score >= 90:        return "A"    elif score >= 80:        return "B"    else:        return "C"print(get_grade(student1))  # B

看起来还行,但问题来了:如果有 100 个学生呢?如果有人误把 "score" 写成 "scroe" 呢?如果还要加入课程、学分等信息呢?字典加函数的模式会越来越难以维护。

面向对象就是来解决这类问题的——把数据和操作数据的函数绑定在一起,形成一个逻辑单元:类


二、类与对象:蓝图与房子

类(Class) 是蓝图,对象(Object) 是按蓝图造出来的房子。一份蓝图可以造无数个房子,一个类可以实例化出无数个对象。

2.1 定义你的第一个类

class Student:    """学生类"""    # 类属性(所有实例共享)    school = "一中"    # 初始化方法 —— 创建对象时自动调用    def __init__(self, name, age, score):        # 实例属性(每个实例独有)        self.name = name        self.age = age        self.score = score    # 实例方法    def get_grade(self):        """根据成绩返回等级"""        if self.score >= 90:            return "A"        elif self.score >= 80:            return "B"        elif self.score >= 60:            return "C"        else:            return "D"    def introduce(self):        """自我介绍"""        return f"我叫{self.name},今年{self.age}岁,成绩等级{self.get_grade()}"# 创建对象(实例化)s1 = Student("小明", 20, 85)s2 = Student("小红", 21, 92)print(s1.introduce())   # 我叫小明,今年20岁,成绩等级Bprint(s2.introduce())   # 我叫小红,今年21岁,成绩等级Aprint(s1.school)        # 一中(类属性,所有实例共享)print(s2.school)        # 一中

逐行解读关键概念:

  • • class Student:  — 定义一个名为 Student 的类,命名习惯用大驼峰(每个单词首字母大写)。
  • •  __init__(self, ...)  — 初始化方法,创建对象时自动调用。self 代表当前实例对象,是必须写的第一参数(名字约定俗成叫 self,但你用 me 也行)。
  • • self.name = name — 把传入的 name 绑定到当前实例上,成为实例属性。
  • • s1 = Student("小明", 20, 85)  — 实例化,会触发 __init__s1 就是创建出来的对象。

2.2 类属性 vs 实例属性

class Dog:    species = "犬科"           # 类属性 —— 所有狗共享    def __init__(self, name, age):        self.name = name       # 实例属性 —— 每条狗独有        self.age = aged1 = Dog("旺财", 3)d2 = Dog("来福", 5)# 实例属性互不影响print(d1.name)    # 旺财print(d2.name)    # 来福# 类属性共享print(d1.species)  # 犬科print(d2.species)  # 犬科# 通过实例修改类属性:小心!d1.species = "猫科"           # 这只是在 d1 上创建了一个同名的实例属性!print(d1.species)  # 猫科     (实例属性,覆盖了类属性)print(d2.species)  # 犬科     (仍然读取类属性)print(Dog.species) # 犬科     (类属性没变)# 正确修改类属性Dog.species = "犬科动物"print(d2.species)  # 犬科动物

经验法则:如果某个属性对所有实例都一样,用类属性;如果每个实例不同,用实例属性。


三、三大特性(上):封装

封装的核心思想是:隐藏内部实现细节,只暴露必要的接口。就像你用手机,不需要知道芯片怎么工作,只需要按开机键就行。

3.1 公有与私有

Python 没有 Java/C++ 那种强制访问控制,而是靠约定

class BankAccount:    def __init__(self, owner, balance):        self.owner = owner          # 公有属性        self._bank = "中国银行"      # 单下划线 —— "受保护的",约定不直接访问        self.__balance = balance    # 双下划线 —— "私有的",名称会被改写    def deposit(self, amount):        """存款 —— 公开接口"""        if amount > 0:            self.__balance += amount            return f"存入 {amount} 元,余额 {self.__balance} 元"        return "金额无效"    def withdraw(self, amount):        """取款 —— 公开接口"""        if 0 < amount <= self.__balance:            self.__balance -= amount            return f"取出 {amount} 元,余额 {self.__balance} 元"        return "余额不足或金额无效"    def get_balance(self):        """查询余额 —— 唯一查看余额的合法途径"""        return self.__balanceacc = BankAccount("小明", 1000)print(acc.deposit(500))      # 存入 500 元,余额 1500 元print(acc.withdraw(200))     # 取出 200 元,余额 1300 元print(acc.get_balance())     # 1300# 直接访问私有属性会怎样?# print(acc.__balance)       # AttributeError!print(acc._BankAccount__balance)  # 1300(名称改写后仍可访问,但不应该这样做)

关键点:

  • •  _name — 单下划线,约定为内部使用,外部可以访问但 IDE 会提示"你不该用"。
  • •  __name — 双下划线,触发名称改写(name mangling),变成 _ClassName__name,防止被子类意外覆盖,同时对外隐藏。
  • • Python 社区信奉"我们都是成年人了"——没有绝对的私有,约定大于强制。

3.2 property 装饰器:优雅的 getter/setter

class Student:    def __init__(self, name, score):        self.name = name        self._score = score    @property    def score(self):        """读取成绩"""        return self._score    @score.setter    def score(self, value):        """设置成绩,带校验"""        if not 0 <= value <= 100:            raise ValueError("成绩必须在 0~100 之间")        self._score = value    @property    def grade(self):        """等级 —— 计算属性(只读)"""        if self._score >= 90:            return "A"        elif self._score >= 80:            return "B"        elif self._score >= 60:            return "C"        else:            return "D"s = Student("小明", 85)print(s.score)   # 85(像访问属性一样调用方法)print(s.grade)   # B(计算属性)s.score = 95     # 直接赋值,自动走 setter 校验print(s.grade)   # A# s.score = 150  # ValueError: 成绩必须在 0~100 之间

用 @property 的好处:调用方不需要记住 get_score() 和 set_score(),直接 obj.score 即可,同时校验逻辑一行不少——把属性访问变成方法调用。


四、三大特性(中):继承

继承就像父母把财产传给子女——子类自动获得父类的所有属性和方法,还能添加自己的东西或修改已有的。

4.1 基本继承

# 父类(基类)class Animal:    def __init__(self, name):        self.name = name    def speak(self):        return "..."    def info(self):        return f"我叫{self.name}"# 子类(派生类)class Dog(Animal):    def speak(self):           # 重写(override)父类方法        return "汪汪汪!"    def wag_tail(self):        # 新增方法        return f"{self.name} 摇起了尾巴"class Cat(Animal):    def speak(self):        return "喵喵喵~"d = Dog("旺财")c = Cat("咪咪")print(d.info(), d.speak(), d.wag_tail())# 我叫旺财 汪汪汪! 旺财 摇起了尾巴print(c.info(), c.speak())# 我叫咪咪 喵喵喵~# 类型检查print(isinstance(d, Dog))     # Trueprint(isinstance(d, Animal))  # True —— 子类实例也是父类实例print(issubclass(Dog, Animal)) # True

4.2 super():调用父类方法

class Smartphone:    def __init__(self, brand, model):        self.brand = brand        self.model = model    def info(self):        return f"{self.brand} {self.model}"class SmartPhone5G(Smartphone):    def __init__(self, brand, model, band):        # 调用父类的 __init__,避免重复 self.brand = ..., self.model = ...        super().__init__(brand, model)        self.band = band          # 子类自己的属性    def info(self):        base = super().info()     # 复用父类的方法        return f"{base}(5G 频段:{self.band})"phone = SmartPhone5G("华为", "Mate 60", "n78/n79")print(phone.info())   # 华为 Mate 60(5G 频段:n78/n79)

使用super()是 Python 的最佳实践,比硬编码 父类名.__init__(self, ...) 更好——它遵循 MRO(方法解析顺序),在多重继承场景下尤其重要。

4.3 多重继承与 MRO

Python 支持多重继承(一个类同时继承多个父类):

class Flyable:    def fly(self):        return "飞起来了~"class Swimmable:    def swim(self):        return "游起来了~"class Duck(Animal, Flyable, Swimmable):    def speak(self):        return "嘎嘎嘎!"duck = Duck("唐老鸭")print(duck.speak())  # 嘎嘎嘎!print(duck.fly())    # 飞起来了~print(duck.swim())   # 游起来了~# 查看方法解析顺序print(Duck.__mro__)# (Duck, Animal, Flyable, Swimmable, object)

多重继承很强大,但也容易造成混乱("钻石问题")。MRO(Method Resolution Order)决定了当多个父类有同名方法时,Python 按什么顺序查找——采用 C3 线性化算法,保证每个父类在子类之前被检查,且保持继承顺序。

建议:大多数场景下单继承就够用了,多重继承留到确实需要 mixin 模式时再用。


五、三大特性(下):多态

多态的核心是同一个接口,不同实现。你不需要知道对象具体是什么类型,只要它有这个方法就能调用——这就是"鸭子类型"。

5.1 鸭子类型

"如果它走起来像鸭子,叫起来像鸭子,那它就是鸭子。"

class Guitar:    def play(self):        return "弹奏吉他:🎸"class Piano:    def play(self):        return "弹奏钢琴:🎹"class Drum:    def play(self):        return "敲击架子鼓:🥁"# 多态:不关心是什么乐器,有 play() 就能演奏def perform(instrument):    print(instrument.play())perform(Guitar())   # 弹奏吉他:🎸perform(Piano())    # 弹奏钢琴:🎹perform(Drum())     # 敲击架子鼓:🥁# 甚至可以传任何有 play() 方法的对象class Singer:    def play(self):        return "歌手清唱:🎤"perform(Singer())   # 歌手清唱:🎤

Python 多态不依赖于继承——只要对象提供了需要的方法,就能正常工作。这比 Java/C++ 基于接口/抽象类的多态更灵活。

5.2 抽象基类(可选的高级约束)

如果你希望强制子类实现某些方法(更像 Java 的 interface),可以用 abc 模块:

from abc import ABC, abstractmethodclass Shape(ABC):    @abstractmethod    def area(self):        """子类必须实现"""        pass    @abstractmethod    def perimeter(self):        """子类必须实现"""        passclass Circle(Shape):    def __init__(self, radius):        self.radius = radius    def area(self):        return 3.14159 * self.radius ** 2    def perimeter(self):        return 2 * 3.14159 * self.radiusclass Rectangle(Shape):    def __init__(self, width, height):        self.width = width        self.height = height    def area(self):        return self.width * self.height    def perimeter(self):        return 2 * (self.width + self.height)# shape = Shape()   # TypeError: 不能实例化抽象类shapes = [Circle(5), Rectangle(3, 4)]for s in shapes:    print(f"面积:{s.area():.2f},周长:{s.perimeter():.2f}")# 面积:78.54,周长:31.42# 面积:12.00,周长:14.00

六、综合实战:一个简单的图书管理系统

把封装、继承、多态揉在一起:

class Book:    """书籍类"""    def __init__(self, title, author, isbn):        self.title = title        self.author = author        self.isbn = isbn        self._available = True    # 是否可借    @property    def available(self):        return self._available    def borrow(self):        if not self._available:            return f"《{self.title}》已被借出"        self._available = False        return f"借阅成功:《{self.title}》"    def return_book(self):        self._available = True        return f"归还成功:《{self.title}》"    def info(self):        status = "✅ 可借" if self._available else "❌ 已借出"        return f"《{self.title}》- {self.author} [{status}]"class Library:    """图书馆类 —— 管理多本书"""    def __init__(self, name):        self.name = name        self._books = []          # 组合:图书馆包含书籍    def add_book(self, book):        self._books.append(book)        print(f"入库:《{book.title}》")    def search(self, keyword):        """按书名或作者搜索"""        results = [            b for b in self._books            if keyword in b.title or keyword in b.author        ]        return results    def total(self):        """返回藏书总数"""        return len(self._books)    def has_book(self, title):        """判断某书是否在馆"""        return any(title == b.title for b in self._books)    def list_books(self):        """列出所有藏书"""        print(f"\n=== {self.name} 藏书列表 ===")        if not self._books:            print("(空)")            return        for i, book in enumerate(self._books, 1):            print(f"  {i}. {book.info()}")        print()# 使用lib = Library("阳光图书馆")lib.add_book(Book("Python编程:从入门到实践", "Eric Matthes", "978-7-115-54608-8"))lib.add_book(Book("流畅的Python", "Luciano Ramalho", "978-7-115-45415-5"))lib.add_book(Book("Python Cookbook", "David Beazley", "978-7-115-37959-7"))lib.list_books()# 借阅book = lib.search("流畅")[0]print(book.borrow())           # 借阅成功:《流畅的Python》print(book.borrow())           # 《流畅的Python》已被借出print(book.return_book())      # 归还成功:《流畅的Python》# 查询print(f"馆藏数量:{lib.total()} 本")           # 馆藏数量:3 本print(f"有《流畅的Python》吗?{lib.has_book(&#x27;流畅的Python&#x27;)}")  # True# 查看最终状态lib.list_books()

这个例子虽然小巧,但已经展示了面向对象的完整用法——类与对象、属性与方法、封装(_available + property)、继承(虽然没有显式写出,但所有类都继承自 object)、组合(Library 包含 Book)、多态(search 返回的 Book 对象都可以调用 borrowreturn_book 等方法)。


七、动手练习

  1. 1. 定义一个 Rectangle 类,有 width 和 height 属性,通过方法 area() 返回面积,perimeter() 返回周长。用 property 把面积做成只读计算属性。
  2. 2. 定义一个 BankAccount 的子类 SavingsAccount,增加利率属性 rate,添加 add_interest() 方法让余额按利率增值。
  3. 3. 定义一个 Employee 基类,包含 name 和 salary 属性以及 get_info() 方法;再定义一个 Manager 子类,增加 department 属性和 bonus 属性,重写 get_info() 方法输出完整信息。
  4. 4. 用鸭子类型写一个函数 describe(obj),只要传入的对象有 name 属性和 speak() 方法就调用并打印结果。再创建两三个不相关的类来测试它。

八、小结

本篇带你完成了 Python 面向对象的基础入门:

  • • 类与对象:类是蓝图,对象是实例。__init__ 初始化实例属性,self 代表自身。
  • • 封装:公私有约定(_ 和 __),@property 让属性访问带校验。
  • • 继承:子类复用父类代码,super() 调用父类方法,MRO 决定查找顺序。
  • • 多态:鸭子类型——不关心对象类型,只关心有没有对应方法。

面向对象编程不只是 Python 的特性,更是一种思维方式。用类来组织代码,让数据和逻辑聚合在一起,项目的可维护性和扩展性都会有质的提升。

下一篇,我们将探讨文件操作与异常处理,让你的程序不仅能"算"、能"想",还能读写文件、优雅地处理错误。不见不散!


本文首发于微信公众号「羽您码上聊」,欢迎关注获取更多技术内容。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-04 03:11:18 HTTP/2.0 GET : https://f.mffb.com.cn/a/499072.html
  2. 运行时间 : 0.185318s [ 吞吐率:5.40req/s ] 内存消耗:5,043.86kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=bc3580e2ac8ca1a31714becb5d501454
  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.000603s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000586s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.012125s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000778s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000728s ]
  6. SELECT * FROM `set` [ RunTime:0.001245s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000623s ]
  8. SELECT * FROM `article` WHERE `id` = 499072 LIMIT 1 [ RunTime:0.000487s ]
  9. UPDATE `article` SET `lasttime` = 1783105878 WHERE `id` = 499072 [ RunTime:0.005480s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000335s ]
  11. SELECT * FROM `article` WHERE `id` < 499072 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.005486s ]
  12. SELECT * FROM `article` WHERE `id` > 499072 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.013480s ]
  13. SELECT * FROM `article` WHERE `id` < 499072 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.018643s ]
  14. SELECT * FROM `article` WHERE `id` < 499072 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.031662s ]
  15. SELECT * FROM `article` WHERE `id` < 499072 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.021703s ]
0.186831s