当前位置:首页>python>Python 零基础100天—Day17 异常处理

Python 零基础100天—Day17 异常处理

  • 2026-07-02 16:33:33
Python 零基础100天—Day17 异常处理

🐍 Python Day17:异常处理 — 让程序不再崩溃

🕐 预计用时:2-3 小时 | 🎯 目标:掌握 try/except/else/finally、自定义异常、常见异常类型


📖 今日目录

  1. 什么是异常?
  2. try / except:捕获异常
  3. 捕获多种异常
  4. try / except / else / finally 完整结构
  5. 常见异常类型大全
  6. 自定义异常
  7. 异常链与 raise from
  8. 实战练习
  9. 今日小结

1. 什么是异常?

异常是程序运行时的"意外事件"——不是语法错误,而是执行过程中出了问题。

# 语法错误(SyntaxError):代码写错了,运行前就被拦截
# print("hello"    # ❌ 缺少右括号

# 异常(Exception):代码语法正确,但运行时出错
print(10 / 0)        # ❌ ZeroDivisionError: division by zero

# 没有异常处理:程序直接崩溃
print("程序开始")
result = 10 / 0       # 💥 崩溃!后面的代码不会执行
print("程序结束")     # ← 不会运行
# 有异常处理:程序优雅地处理错误
print("程序开始")
try:
    result = 10 / 0
except ZeroDivisionError:
    print("❌ 错误:不能除以零!")
print("程序结束")     # ← 正常运行

# 输出:
# 程序开始
# ❌ 错误:不能除以零!
# 程序结束
对比
不处理异常
处理异常
程序状态
💥 直接崩溃
✅ 继续运行
用户体验
看到一堆红色报错
看到友好的提示
数据安全
可能丢失未保存数据
可以做清理和保存

2. try / except:捕获异常

📖 基本语法

# try 块里放可能出错的代码
# except 块里放出错后怎么处理
try:
    num = int(input("请输入一个数字: "))
    result = 100 / num
    print(f"100 / {num} = {result}")
except ValueError:
    print("❌ 输入的不是数字!")
except ZeroDivisionError:
    print("❌ 不能除以零!")

🔍 获取异常信息

# 用 as 关键字获取异常对象
try:
    num = int("abc")
except ValueError as e:
    print(f"错误类型: {type(e).__name__}")
    print(f"错误信息: {e}")
    print(f"错误参数: {e.args}")

# 输出:
# 错误类型: ValueError
# 错误信息: invalid literal for int() with base 10: 'abc'
# 错误参数: ("invalid literal for int() with base 10: 'abc'",)
# 文件操作中的异常处理
try:
    with open("不存在的文件.txt", "r", encoding="utf-8") as f:
        content = f.read()
except FileNotFoundError as e:
    print(f"❌ 文件不存在: {e}")
    print("将创建新文件...")
    with open("不存在的文件.txt", "w", encoding="utf-8") as f:
        f.write("这是新创建的文件\n")

3. 捕获多种异常

📋 方式一:多个 except

# 每种异常单独处理
try:
    data = {"name": "张三"}
    num = int(input("输入数字: "))
    result = data["age"] / num
except ValueError:
    print("❌ 输入不是数字")
except ZeroDivisionError:
    print("❌ 不能除以零")
except KeyError as e:
    print(f"❌ 键不存在: {e}")

📋 方式二:合并捕获

# 多种异常,同一种处理方式
try:
    num = int(input("输入数字: "))
    result = 100 / num
except (ValueError, ZeroDivisionError) as e:
    print(f"❌ 出错了: {e}")

📋 方式三:万能捕获

# ⚠️ 不推荐:捕获所有异常(会掩盖 bug)
try:
    # 一堆可能出错的代码
    result = 10 / 0
except Exception as e:
    print(f"❌ 出错了: {type(e).__name__}: {e}")

# ❌ 千万不要这样写!
# except:  ← 裸 except,比 Exception 更危险
#     pass  ← 静默吞掉所有异常,bug 永远找不到

⚠️ 异常捕获的原则:
1. 尽量捕获具体的异常,而不是 Exception
2. 不要用裸 except(不带异常类型的 except)
3. 不要用 pass 静默吞掉异常(至少要记日志)
4. 让程序崩溃有时候比静默失败更好——至少你知道出错了


4. try / except / else / finally 完整结构

try:
    # 可能出错的代码
    num = int(input("输入数字: "))
    result = 100 / num

except ValueError:
    # 出错时执行(特定异常)
    print("❌ 不是数字")

except ZeroDivisionError:
    # 出错时执行(特定异常)
    print("❌ 不能除以零")

except Exception as e:
    # 出错时执行(其他异常)
    print(f"❌ 未知错误: {e}")

else:
    # 没有出错时执行 ✅
    print(f"✅ 结果: {result}")

finally:
    # 无论如何都会执行 ✅(清理工作)
    print("🔄 处理完毕")

🔍 执行流程图

情况
try
except
else
finally
没有异常
✅ 执行
❌ 跳过
✅ 执行
✅ 执行
有异常且被捕获
✅ 执行到出错行
✅ 执行
❌ 跳过
✅ 执行
有异常但没被捕获
✅ 执行到出错行
❌ 不匹配
❌ 跳过
✅ 执行 → 然后崩溃
# 实际示例:安全的文件读取
def safe_read_file(filename):
    """安全读取文件,带完整异常处理"""
    f = None
    try:
        f = open(filename, "r", encoding="utf-8")
        content = f.read()
    except FileNotFoundError:
        print(f"❌ 文件不存在: {filename}")
        return None
    except PermissionError:
        print(f"❌ 没有权限读取: {filename}")
        return None
    except UnicodeDecodeError:
        print(f"❌ 编码错误: {filename}(尝试其他编码)")
        return None
    except Exception as e:
        print(f"❌ 未知错误: {e}")
        return None
    else:
        print(f"✅ 成功读取 {len(content)} 个字符")
        return content
    finally:
        if f:
            f.close()
        print("🔄 文件操作完成")

# with 语句版(更简洁)
def safe_read_file_v2(filename):
    """更简洁的写法(with 自动关闭)"""
    try:
        with open(filename, "r", encoding="utf-8") as f:
            return f.read()
    except FileNotFoundError:
        print(f"❌ 文件不存在: {filename}")
        return None

💡 finally 的典型用途:
1. 关闭文件/数据库连接
2. 释放锁
3. 记录日志
4. 清理临时文件
一句话:finally = 无论成功失败都要做的事


5. 常见异常类型大全

异常类型
触发条件
示例
ValueError
值不合法
int("abc")
TypeError
类型不匹配
"a" + 1
KeyError
字典键不存在
{}["key"]
IndexError
列表索引越界
[][0]
ZeroDivisionError
除以零
1/0
FileNotFoundError
文件不存在
open("x.txt")
PermissionError
没有权限
写入只读文件
AttributeError
属性/方法不存在
"a".foo()
NameError
变量未定义
print(x)
ImportError
导入模块失败
import xxx
StopIteration
迭代器耗尽
next(iter([]))
OverflowError
数值溢出
math.exp(1000)
RecursionError
递归过深
无限递归
KeyboardInterrupt
用户按 Ctrl+C
手动中断
# 常见异常演示
# ValueError
try:
    num = int("hello")
except ValueError as e:
    print(f"ValueError: {e}")

# KeyError
try:
    d = {"name": "张三"}
    print(d["age"])
except KeyError as e:
    print(f"KeyError: 键 {e} 不存在")

# IndexError
try:
    lst = [1, 2, 3]
    print(lst[10])
except IndexError as e:
    print(f"IndexError: {e}")

# AttributeError
try:
    s = "hello"
    s.push("!")
except AttributeError as e:
    print(f"AttributeError: {e}")

# FileNotFoundError
try:
    open("ghost.txt")
except FileNotFoundError:
    print("FileNotFoundError: 文件不存在")

🏗️ 异常继承层级(了解即可)

BaseException
 ├── KeyboardInterrupt       # Ctrl+C
 ├── SystemExit              # sys.exit()
 └── Exception               # 所有常规异常的父类
      ├── ValueError
      ├── TypeError
      ├── KeyError
      ├── IndexError
      ├── ZeroDivisionError
      ├── FileNotFoundError → OSError
      ├── PermissionError   → OSError
      ├── AttributeError
      ├── NameError
      ├── ImportError
      └── ...

# 捕获 Exception = 捕获所有常规异常(不包括 KeyboardInterrupt 等)

6. 自定义异常

当内置异常不够用时,创建你自己的异常类。

# 自定义异常:继承 Exception
class AgeError(Exception):
    """年龄不合法异常"""
    def __init__(self, age, message="年龄必须在 0-150 之间"):
        self.age = age
        self.message = message
        super().__init__(self.message)

    def __str__(self):
        return f"{self.message}(实际值: {self.age})"

class InsufficientFundsError(Exception):
    """余额不足异常"""
    def __init__(self, balance, amount):
        self.balance = balance
        self.amount = amount
        self.deficit = amount - balance
        super().__init__(f"余额不足:需要 {amount},余额 {balance},差额 {self.deficit}")

# 使用自定义异常
def set_age(age):
    if age < 0 or age > 150:
        raise AgeError(age)
    print(f"年龄设置为: {age}")

def withdraw(balance, amount):
    if amount > balance:
        raise InsufficientFundsError(balance, amount)
    return balance - amount

# 捕获自定义异常
try:
    set_age(200)
except AgeError as e:
    print(f"❌ {e}")
    print(f"   无效年龄: {e.age}")

try:
    new_balance = withdraw(100, 250)
except InsufficientFundsError as e:
    print(f"❌ {e}")
    print(f"   差额: {e.deficit}")

🎯 raise:主动抛出异常

# raise 主动抛出异常
def divide(a, b):
    if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
        raise TypeError("参数必须是数字")
    if b == 0:
        raise ZeroDivisionError("除数不能为零")
    return a / b

# 调用者处理
try:
    result = divide("10", 2)
except TypeError as e:
    print(f"❌ {e}")

try:
    result = divide(10, 0)
except ZeroDivisionError as e:
    print(f"❌ {e}")

💡 什么时候自定义异常?
1. 内置异常无法准确描述你的错误
2. 需要携带额外信息(如余额、差额)
3. 构建框架/库,需要异常层级
4. 业务逻辑错误(如密码错误、权限不足)


7. 异常链与 raise from

# 异常链:保留原始异常信息
def read_config(filename):
    try:
        with open(filename, "r") as f:
            import json
            return json.load(f)
    except FileNotFoundError as e:
        # raise from 保留原始异常
        raise RuntimeError(f"配置文件加载失败: {filename}") from e
    except json.JSONDecodeError as e:
        raise RuntimeError(f"配置文件格式错误: {filename}") from e

try:
    config = read_config("不存在.json")
except RuntimeError as e:
    print(f"❌ {e}")
    print(f"   原因: {e.__cause__}")
# 抑制异常链
try:
    num = int("abc")
except ValueError:
    raise RuntimeError("转换失败")  # 自动链式关联
    # raise RuntimeError("转换失败") from None  # 抑制链式关联

8. 实战练习

🎯 练习 1:安全输入验证器

def safe_input(prompt, type_func=str, validator=None, error_msg="输入无效"):
    """
    安全的输入函数:自动处理异常

    参数:
        prompt: 提示信息
        type_func: 类型转换函数(int/float/str)
        validator: 验证函数(返回 bool)
        error_msg: 错误提示
    """
    while True:
        try:
            value = type_func(input(prompt))
            if validator and not validator(value):
                print(f"❌ {error_msg}")
                continue
            return value
        except ValueError:
            print(f"❌ 请输入有效的{type_func.__name__}类型")
        except KeyboardInterrupt:
            print("\n👋 用户取消")
            return None

# 使用
age = safe_input(
    "请输入年龄: ",
    type_func=int,
    validator=lambda x: 0 < x < 150,
    error_msg="年龄必须在 0-150 之间"
)
if age is not None:
    print(f"✅ 年龄: {age}")

score = safe_input(
    "请输入成绩: ",
    type_func=float,
    validator=lambda x: 0 <= x <= 100,
    error_msg="成绩必须在 0-100 之间"
)
if score is not None:
    print(f"✅ 成绩: {score}")

🎯 练习 2:数据库模拟器(异常驱动)

class DatabaseError(Exception):
    """数据库基础异常"""
    pass

class RecordNotFoundError(DatabaseError):
    """记录未找到"""
    def __init__(self, table, key):
        self.table = table
        self.key = key
        super().__init__(f"在 {table} 中未找到记录: {key}")

class DuplicateKeyError(DatabaseError):
    """键重复"""
    def __init__(self, table, key):
        self.table = table
        self.key = key
        super().__init__(f"在 {table} 中键已存在: {key}")

class MiniDB:
    """简易内存数据库"""
    def __init__(self):
        self.tables = {}

    def create_table(self, name):
        if name in self.tables:
            raise DatabaseError(f"表已存在: {name}")
        self.tables[name] = {}
        print(f"✅ 创建表: {name}")

    def insert(self, table, key, value):
        if table not in self.tables:
            raise DatabaseError(f"表不存在: {table}")
        if key in self.tables[table]:
            raise DuplicateKeyError(table, key)
        self.tables[table][key] = value
        print(f"✅ 插入: {table}[{key}] = {value}")

    def get(self, table, key):
        if table not in self.tables:
            raise DatabaseError(f"表不存在: {table}")
        if key not in self.tables[table]:
            raise RecordNotFoundError(table, key)
        return self.tables[table][key]

    def update(self, table, key, value):
        if table not in self.tables:
            raise DatabaseError(f"表不存在: {table}")
        if key not in self.tables[table]:
            raise RecordNotFoundError(table, key)
        self.tables[table][key] = value
        print(f"✅ 更新: {table}[{key}] = {value}")

    def delete(self, table, key):
        if table not in self.tables:
            raise DatabaseError(f"表不存在: {table}")
        if key not in self.tables[table]:
            raise RecordNotFoundError(table, key)
        del self.tables[table][key]
        print(f"✅ 删除: {table}[{key}]")

# 使用
db = MiniDB()
db.create_table("users")
db.insert("users", "u001", {"name": "张三", "age": 25})
db.insert("users", "u002", {"name": "李四", "age": 30})

# 正常查询
user = db.get("users", "u001")
print(f"查询结果: {user}")

# 异常处理
try:
    db.insert("users", "u001", {"name": "重复"})  # 重复键
except DuplicateKeyError as e:
    print(f"❌ {e}")

try:
    db.get("users", "u999")  # 不存在
except RecordNotFoundError as e:
    print(f"❌ {e}")

try:
    db.get("orders", "o001")  # 表不存在
except DatabaseError as e:
    print(f"❌ {e}")

🎯 练习 3:重试装饰器

import time

def retry(max_attempts=3, delay=1, exceptions=(Exception,)):
    """
    重试装饰器:函数出错时自动重试

    参数:
        max_attempts: 最大重试次数
        delay: 重试间隔(秒)
        exceptions: 需要重试的异常类型
    """
    def decorator(func):
        def wrapper(*args, **kwargs):
            last_exception = None
            for attempt in range(1, max_attempts + 1):
                try:
                    return func(*args, **kwargs)
                except exceptions as e:
                    last_exception = e
                    print(f"  ⚠️ 第 {attempt} 次失败: {e}")
                    if attempt < max_attempts:
                        print(f"  ⏳ {delay}秒后重试...")
                        time.sleep(delay)
            raise last_exception
        return wrapper
    return decorator

# 模拟不稳定的网络请求
import random

@retry(max_attempts=3, delay=0.5, exceptions=(ConnectionError, TimeoutError))
def fetch_data(url):
    """模拟网络请求"""
    if random.random() < 0.7:  # 70% 概率失败
        raise ConnectionError(f"连接超时: {url}")
    return {"status": "ok", "data": [1, 2, 3]}

# 测试
try:
    result = fetch_data("https://api.example.com/data")
    print(f"✅ 请求成功: {result}")
except ConnectionError as e:
    print(f"❌ 所有重试都失败: {e}")

9. 今日小结

知识点
核心内容
try / except
捕获异常,防止程序崩溃
except as e
获取异常对象,打印详情
多种异常
多个 except / 合并捕获 / Exception 兜底
else
没有异常时执行
finally
无论如何都执行(清理工作)
raise
主动抛出异常
自定义异常
继承 Exception,携带额外信息
异常链
raise from
 保留原始异常

🧠 记忆口诀:
try 放可能出错码,except 捕获来善后。
else 没错才执行,finally 一定跑。
raise 抛出自定义,as e 拿到错误码。
具体异常具体捕,裸 except 是毒药。

🔮 预告: Day 18 模块与包 — import__name__、pip 安装第三方库。代码组织的下一步!

轻松时刻:

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 08:13:49 HTTP/2.0 GET : https://f.mffb.com.cn/a/495711.html
  2. 运行时间 : 0.101419s [ 吞吐率:9.86req/s ] 内存消耗:4,510.92kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=98d08f3402b715be8bb962289b789000
  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.000484s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000741s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000249s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000243s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000460s ]
  6. SELECT * FROM `set` [ RunTime:0.000204s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000532s ]
  8. SELECT * FROM `article` WHERE `id` = 495711 LIMIT 1 [ RunTime:0.000783s ]
  9. UPDATE `article` SET `lasttime` = 1783037629 WHERE `id` = 495711 [ RunTime:0.012604s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000292s ]
  11. SELECT * FROM `article` WHERE `id` < 495711 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.005157s ]
  12. SELECT * FROM `article` WHERE `id` > 495711 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000707s ]
  13. SELECT * FROM `article` WHERE `id` < 495711 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.008585s ]
  14. SELECT * FROM `article` WHERE `id` < 495711 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001403s ]
  15. SELECT * FROM `article` WHERE `id` < 495711 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002381s ]
0.103044s