当前位置:首页>python>Python异常处理最佳实践指南

Python异常处理最佳实践指南

  • 2026-02-27 02:50:23
Python异常处理最佳实践指南

嘿,Python学习搭子!今天咱们来聊聊异常处理那些事儿。你可能已经知道 try...except 的基本用法,但在实际项目中,异常处理可不是随便写写就行的。处理得好,代码健壮又优雅;处理不好,可能比 bug 本身还让人头疼。

别慌,我帮你总结了 8 个异常处理最佳实践,每个都有场景说明、代码对比和适用建议。看完之后,你就能写出既安全又易维护的异常处理代码啦!

1. 精确捕获异常,避免“裸 except”

场景:你想捕获文件读取时可能发生的错误,但又不希望把其他无关异常也吞掉。

错误做法

try:withopen("data.txt""r"as f:        content = f.read()except:  # 裸 except,捕获所有异常,包括 KeyboardInterrupt、SystemExit 等print("出错了")

正确做法

try:withopen("data.txt""r"as f:        content = f.read()except FileNotFoundError:print("文件不存在,检查路径是否正确")except PermissionError:print("没有读取权限")except IOError as e:print(f"读取文件时发生IO错误: {e}")

适用场景

  • • 当你确切知道可能发生哪些异常时
  • • 需要对不同类型的异常做不同处理
  • • 避免意外捕获 KeyboardInterrupt(Ctrl+C)等系统级异常

小贴士:如果你真的需要捕获所有异常(比如在最外层日志记录),至少要用 except Exception:,这样不会捕获系统退出异常。

2. 善用 else 子句,让代码更清晰

场景:当 try 块中的代码没有抛出异常时,你想执行一些后续操作。

错误做法

try:    result = risky_operation()# 如果没有异常,继续处理    processed = process_result(result)except SomeError:    handle_error()

问题:processed = process_result(result) 放在 try 块中,如果 process_result 抛出异常,会被错误地当成 risky_operation 的异常处理。

正确做法

try:    result = risky_operation()except SomeError:    handle_error()else:# 只有 risky_operation 成功时才执行    processed = process_result(result)

适用场景

  • • 需要区分“操作成功”和“成功后的处理”
  • • 避免异常处理范围过大
  • • 让代码逻辑更清晰

一句话总结else 是 try 的“成功回调”,finally 是“无论如何都要执行”。

3. 使用 finally 确保资源清理

场景:你需要确保文件、数据库连接、网络套接字等资源在任何情况下都能被正确关闭。

错误做法

file = open("data.txt""r")try:    data = file.read()    process(data)except IOError:print("读取失败")# 如果这里发生异常,file 可能不会被关闭file.close()

正确做法

file = open("data.txt""r")try:    data = file.read()    process(data)except IOError:print("读取失败")finally:    file.close()  # 无论是否发生异常,都会执行

更优雅的做法:使用 with 语句(见下一个最佳实践)

适用场景

  • • 任何需要确保清理操作的场景
  • • 即使发生异常也不能忘记的收尾工作

4. 优先使用 with 语句管理资源

场景:处理文件、数据库连接、锁等需要明确生命周期管理的资源。

错误做法

file = Nonetry:    file = open("data.txt""r")    data = file.read()except IOError:print("读取失败")finally:if file:        file.close()

正确做法

withopen("data.txt""r"as file:    data = file.read()# 离开 with 块后,文件会自动关闭,即使发生异常也不例外

适用场景

  • • 任何实现了上下文管理器协议(__enter__ 和 __exit__ 方法)的对象
  • • 文件操作、数据库连接、线程锁、临时目录等

扩展应用:你还可以创建自己的上下文管理器!

from contextlib import contextmanager@contextmanagerdefdatabase_connection(connection_string):    conn = create_connection(connection_string)try:yield connfinally:        conn.close()# 使用with database_connection("mysql://user:pass@localhost/db"as conn:    results = conn.execute_query("SELECT * FROM users")

5. 设计有意义的自定义异常

场景:你的应用程序有特定的错误情况,需要明确的异常类型来表示。

错误做法

defprocess_user(user_id):    user = get_user(user_id)ifnot user:raise ValueError("用户不存在")  # 不够明确if user.age < 18:raise ValueError("用户未成年")  # 与上面的 ValueError 无法区分

正确做法

classUserNotFoundError(Exception):"""用户不存在异常"""passclassUnderageUserError(Exception):"""用户未成年异常"""passdefprocess_user(user_id):    user = get_user(user_id)ifnot user:raise UserNotFoundError(f"用户ID {user_id} 不存在")if user.age < 18:raise UnderageUserError(f"用户 {user_id} 未成年,年龄 {user.age}")

适用场景

  • • 应用程序有特定的业务逻辑错误
  • • 需要区分不同类型的错误以便不同处理
  • • 提高代码可读性和可维护性

设计原则

  1. 1. 异常名以 Error 结尾
  2. 2. 继承自 Exception 或其子类
  3. 3. 提供有意义的错误信息
  4. 4. 考虑异常层级结构(比如 ValidationError 可以有 EmailValidationErrorPasswordValidationError 等子类)

6. 使用异常链保留原始上下文

场景:在捕获异常并重新抛出时,你希望保留原始异常的信息,方便调试。

错误做法

try:    parse_config("config.yaml")except YAMLError:raise ConfigError("配置文件解析失败")  # 原始 YAMLError 信息丢失了

正确做法

try:    parse_config("config.yaml")except YAMLError as e:raise ConfigError("配置文件解析失败"from e

这样,当 ConfigError 被捕获时,可以通过 __cause__ 属性访问原始的 YAMLError

查看异常链

try:# 一些操作passexcept ConfigError as e:print(f"当前异常: {e}")if e.__cause__:print(f"原始异常: {e.__cause__}")

适用场景

  • • 包装底层异常为高层异常时
  • • 需要保留完整的错误上下文链
  • • 调试复杂的多层调用

7. 合理记录异常日志

场景:在生产环境中,你需要记录异常信息以便后续分析,但又不希望日志过于冗长或泄露敏感信息。

错误做法

try:    process_payment(user, amount)except PaymentError:print("支付失败")  # 控制台输出,无法持久化,信息太少

正确做法

import logginglogger = logging.getLogger(__name__)try:    process_payment(user, amount)except PaymentError as e:    logger.error(f"支付处理失败: 用户={user.id}, 金额={amount}", exc_info=True)# exc_info=True 会记录完整的异常回溯信息raise# 根据情况决定是否重新抛出

日志级别建议

  • • logger.debug(): 详细的调试信息,包括变量值
  • • logger.info(): 正常的业务操作记录
  • • logger.warning(): 不严重的问题,但需要注意
  • • logger.error(): 错误情况,需要调查
  • • logger.critical(): 严重错误,可能导致系统无法运行

适用场景

  • • 任何生产环境代码
  • • 需要监控和诊断的问题
  • • 审计和合规要求

注意:避免在日志中记录敏感信息(密码、密钥、个人身份信息等)。

8. 将异常处理与业务逻辑分离

场景:你的业务逻辑代码中混杂了大量的异常处理,导致核心逻辑不清晰。

错误做法

defprocess_order(order):try:# 验证订单ifnot order.is_valid():raise ValidationError("订单无效")# 检查库存try:            check_inventory(order.items)except InventoryError:raise OrderError("库存不足")# 处理支付try:            process_payment(order)except PaymentError:raise OrderError("支付失败")# 更新订单状态        update_order_status(order, "completed")except ValidationError as e:        logger.error(f"订单验证失败: {e}")return {"success"False"error"str(e)}except OrderError as e:        logger.error(f"订单处理失败: {e}")return {"success"False"error"str(e)}except Exception as e:        logger.error(f"未知错误: {e}")return {"success"False"error""系统内部错误"}

正确做法:使用装饰器或上下文管理器分离异常处理

from functools import wrapsdefhandle_order_errors(func):    @wraps(func)defwrapper(*args, **kwargs):try:return func(*args, **kwargs)except ValidationError as e:            logger.error(f"订单验证失败: {e}")return {"success"False"error"str(e)}except OrderError as e:            logger.error(f"订单处理失败: {e}")return {"success"False"error"str(e)}except Exception as e:            logger.error(f"未知错误: {e}")return {"success"False"error""系统内部错误"}return wrapper# 业务逻辑变得清晰@handle_order_errorsdefprocess_order(order):# 验证订单ifnot order.is_valid():raise ValidationError("订单无效")# 检查库存    check_inventory(order.items)  # 可能抛出 InventoryError# 处理支付    process_payment(order)  # 可能抛出 PaymentError# 更新订单状态    update_order_status(order, "completed")return {"success"True}

适用场景

  • • 复杂的业务逻辑需要统一的错误处理
  • • 多个函数有相似的异常处理模式
  • • 希望保持业务逻辑的纯净性

总结与预告

咱们今天一口气看了 8 个异常处理最佳实践,从基础的精确捕获到高级的异常分离,每个都是实战中总结出来的宝贵经验。记住这些原则,你的 Python 代码会变得更加健壮和易维护。

快速回顾一下

  1. 1. ✅ 精确捕获异常,避免裸 except
  2. 2. ✅ 善用 else 子句让逻辑清晰
  3. 3. ✅ 使用 finally 确保资源清理
  4. 4. ✅ 优先使用 with 语句管理资源
  5. 5. ✅ 设计有意义的自定义异常
  6. 6. ✅ 使用异常链保留原始上下文
  7. 7. ✅ 合理记录异常日志
  8. 8. ✅ 将异常处理与业务逻辑分离

下一步该学什么?

下一周咱们要进入 Python 面向对象编程的世界!你会学到:

  • • 类和对象的基本概念
  • • 封装、继承、多态三大特性
  • • 魔术方法(Magic Methods)的妙用
  • • 如何设计优雅的类层次结构

是不是有点小期待?面向对象编程能让你的代码更好地组织,处理复杂问题时游刃有余。

在那之前,建议你把这些异常处理的最佳实践用在实际的小项目中,比如写一个文件处理工具或者简单的命令行应用。实践出真知,动手试试看吧!遇到问题随时找我,你的 Python 学习搭子随时在线 😊

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-28 10:48:39 HTTP/2.0 GET : https://f.mffb.com.cn/a/476273.html
  2. 运行时间 : 0.216130s [ 吞吐率:4.63req/s ] 内存消耗:4,978.30kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=6cb02880dbe34895abd57771271d2981
  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.001110s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001599s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000708s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000660s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001282s ]
  6. SELECT * FROM `set` [ RunTime:0.000584s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001408s ]
  8. SELECT * FROM `article` WHERE `id` = 476273 LIMIT 1 [ RunTime:0.001100s ]
  9. UPDATE `article` SET `lasttime` = 1772246920 WHERE `id` = 476273 [ RunTime:0.015796s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000792s ]
  11. SELECT * FROM `article` WHERE `id` < 476273 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001315s ]
  12. SELECT * FROM `article` WHERE `id` > 476273 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001097s ]
  13. SELECT * FROM `article` WHERE `id` < 476273 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.004132s ]
  14. SELECT * FROM `article` WHERE `id` < 476273 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.012123s ]
  15. SELECT * FROM `article` WHERE `id` < 476273 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.014827s ]
0.219845s