当前位置:首页>python>Python错误和异常详解

Python错误和异常详解

  • 2026-06-21 20:24:56
Python错误和异常详解

1. 概述

在Python编程中,程序执行过程中可能会遇到两种主要问题:错误(Error)和异常(Exception)。理解和正确处理这些问题对于编写健壮、可靠的程序至关重要。

1.1 错误与异常的区别

  • 错误:通常指程序中的语法错误或逻辑错误,导致程序无法正常编译或执行。错误一旦发生,程序将立即终止。

    • 语法错误:不符合Python语法规则的错误
    • 逻辑错误:程序能运行但结果不符合预期
  • 异常:程序执行过程中出现的意外情况,如文件不存在、除以零等。异常可以被捕获和处理,程序可以从异常中恢复并继续执行。

2. 语法错误

语法错误(SyntaxError)是最常见的错误类型,通常是由于不符合Python语法规则导致的。

2.1 常见语法错误

# 缺少冒号
if5>3
print("5大于3")

# 括号不匹配
print("Hello, World!"

# 缩进错误(Python最常见的语法错误)
deffunc():
print("Hello")# 缺少缩进

# 错误的变量名
123abc ="hello"# 变量名不能以数字开头

# 错误的关键字使用
class="Python"# class是关键字,不能用作变量名

2.2 语法错误的处理

语法错误必须在程序运行前修复,Python解释器会指出错误的位置和原因:

  File "example.py", line 2
    if 5 > 3
           ^
SyntaxError: invalid syntax

3. 内置异常类型

Python定义了大量内置异常类,用于表示不同类型的异常情况。这些异常类都继承自BaseException类,形成了一个层次结构。

3.1 异常层次结构

BaseException
├── SystemExit
├── KeyboardInterrupt
├── GeneratorExit
└── Exception
    ├── StopIteration
    ├── StopAsyncIteration
    ├── ArithmeticError
    │   ├── FloatingPointError
    │   ├── OverflowError
    │   └── ZeroDivisionError
    ├── AssertionError
    ├── AttributeError
    ├── BufferError
    ├── EOFError
    ├── ImportError
    │   └── ModuleNotFoundError
    ├── LookupError
    │   ├── IndexError
    │   └── KeyError
    ├── MemoryError
    ├── NameError
    │   └── UnboundLocalError
    ├── OSError
    │   ├── BlockingIOError
    │   ├── ChildProcessError
    │   ├── ConnectionError
    │   │   ├── BrokenPipeError
    │   │   ├── ConnectionAbortedError
    │   │   ├── ConnectionRefusedError
    │   │   └── ConnectionResetError
    │   ├── FileExistsError
    │   ├── FileNotFoundError
    │   ├── InterruptedError
    │   ├── IsADirectoryError
    │   ├── NotADirectoryError
    │   ├── PermissionError
    │   ├── ProcessLookupError
    │   └── TimeoutError
    ├── ReferenceError
    ├── RuntimeError
    │   └── RecursionError
    ├── SyntaxError
    │   └── IndentationError
    │       └── TabError
    ├── SystemError
    ├── TypeError
    ├── ValueError
    │   └── UnicodeError
    │       ├── UnicodeDecodeError
    │       ├── UnicodeEncodeError
    │       └── UnicodeTranslateError
    └── Warning
        ├── DeprecationWarning
        ├── PendingDeprecationWarning
        ├── RuntimeWarning
        ├── SyntaxWarning
        ├── UserWarning
        ├── FutureWarning
        ├── ImportWarning
        ├── UnicodeWarning
        ├── BytesWarning
        └── ResourceWarning

3.2 常见内置异常

异常类型
描述
ZeroDivisionError
除以零
TypeError
类型不匹配
ValueError
值无效
NameError
变量名不存在
IndexError
索引超出范围
KeyError
字典键不存在
FileNotFoundError
文件不存在
PermissionError
权限不足
ImportError
导入模块失败
SyntaxError
语法错误
AttributeError
对象属性不存在
KeyboardInterrupt
用户中断(Ctrl+C)
EOFError
遇到文件结束符

3.3 异常示例

# ZeroDivisionError
try:
    result =10/0
except ZeroDivisionError as e:
print(f"错误: {e}")

# TypeError
try:
    result ="5"+5
except TypeError as e:
print(f"错误: {e}")

# ValueError
try:
    number =int("abc")
except ValueError as e:
print(f"错误: {e}")

# NameError
try:
print(undefined_variable)
except NameError as e:
print(f"错误: {e}")

# IndexError
try:
    my_list =[1,2,3]
print(my_list[5])
except IndexError as e:
print(f"错误: {e}")

# KeyError
try:
    my_dict ={"name":"Zhang San","age":30}
print(my_dict["city"])
except KeyError as e:
print(f"错误: {e}")

# FileNotFoundError
try:
withopen("nonexistent.txt","r")as f:
        content = f.read()
except FileNotFoundError as e:
print(f"错误: {e}")

4. 异常处理机制

Python使用try-except语句来捕获和处理异常,基本语法如下:

try:
# 可能引发异常的代码块
except ExceptionType1:
# 处理ExceptionType1类型的异常
except ExceptionType2:
# 处理ExceptionType2类型的异常
except:
# 处理所有其他类型的异常
else:
# 没有发生异常时执行的代码块
finally:
# 无论是否发生异常都会执行的代码块

4.1 try-except基本用法

# 捕获特定类型的异常
try:
    num1 =int(input("请输入第一个数字: "))
    num2 =int(input("请输入第二个数字: "))
    result = num1 / num2
print(f"结果: {result}")
except ZeroDivisionError:
print("错误: 除数不能为零!")
except ValueError:
print("错误: 请输入有效的整数!")

4.2 捕获多个异常

# 方法1:分别捕获
try:
    num1 =int(input("请输入第一个数字: "))
    num2 =int(input("请输入第二个数字: "))
    result = num1 / num2
print(f"结果: {result}")
except ZeroDivisionError:
print("错误: 除数不能为零!")
except ValueError:
print("错误: 请输入有效的整数!")

# 方法2:捕获多个异常类型
try:
    num1 =int(input("请输入第一个数字: "))
    num2 =int(input("请输入第二个数字: "))
    result = num1 / num2
print(f"结果: {result}")
except(ZeroDivisionError, ValueError)as e:
print(f"错误: {e}")

4.3 捕获所有异常

try:
# 可能引发任何异常的代码
    num1 =int(input("请输入第一个数字: "))
    num2 =int(input("请输入第二个数字: "))
    result = num1 / num2
print(f"结果: {result}")
except Exception as e:
# 捕获所有Exception类型的异常
print(f"发生异常: {e}")
except:
# 捕获所有异常(包括非Exception类型)
print("发生未知异常!")

4.4 else子句

else子句中的代码在try块没有发生异常时执行:

try:
    num1 =int(input("请输入第一个数字: "))
    num2 =int(input("请输入第二个数字: "))
    result = num1 / num2
except(ZeroDivisionError, ValueError)as e:
print(f"错误: {e}")
else:
# 只有在没有异常时才执行
print(f"结果: {result}")
print("计算成功!")

4.5 finally子句

finally子句中的代码无论是否发生异常都会执行,常用于资源清理:

try:
file=open("example.txt","r")
    content =file.read()
print(content)
except FileNotFoundError:
print("错误: 文件不存在!")
finally:
# 无论是否发生异常,都会关闭文件
if'file'inlocals()andnotfile.closed:
file.close()
print("文件已关闭")

# 更简洁的方式(使用with语句)
try:
withopen("example.txt","r")asfile:
        content =file.read()
print(content)
except FileNotFoundError:
print("错误: 文件不存在!")
# with语句自动关闭文件,无需finally

5. 抛出异常

使用raise语句可以主动抛出异常:

5.1 基本用法

defdivide(a, b):
if b ==0:
raise ZeroDivisionError("除数不能为零!")
return a / b

try:
    result = divide(10,0)
except ZeroDivisionError as e:
print(f"捕获到异常: {e}")

5.2 重新抛出异常

try:
    result =10/0
except ZeroDivisionError as e:
print(f"记录错误: {e}")
raise# 重新抛出相同的异常

5.3 抛出不同的异常

try:
    num =int(input("请输入一个正数: "))
if num <=0:
raise ValueError("必须输入正数!")
print(f"您输入的正数是: {num}")
except ValueError as e:
print(f"错误: {e}")

6. 自定义异常

可以通过继承Exception类或其子类来创建自定义异常:

6.1 基本自定义异常

classMyCustomError(Exception):
"""自定义异常类"""
pass

deffunc(value):
if value <0:
raise MyCustomError("值不能为负数!")
return value *2

try:
    result = func(-5)
except MyCustomError as e:
print(f"捕获到自定义异常: {e}")

6.2 带参数的自定义异常

classInvalidAgeError(Exception):
"""年龄无效异常"""
def__init__(self, age, message="年龄必须在0到120之间"):
        self.age = age
        self.message = message
super().__init__(self.message)

def__str__(self):
returnf"{self.age} -> {self.message}"

defcheck_age(age):
if age <0or age >120:
raise InvalidAgeError(age)
returnTrue

try:
    check_age(150)
except InvalidAgeError as e:
print(f"无效年龄: {e}")

6.3 异常层次结构

# 基础异常类
classBaseError(Exception):
pass

# 特定异常类
classInputError(BaseError):
pass

classValidationError(BaseError):
pass

classRangeError(ValidationError):
pass

deffunc(value):
ifnotisinstance(value,int):
raise InputError("必须输入整数!")
if value <0or value >100:
raise RangeError("值必须在0到100之间!")
return value

try:
    result = func("abc")
except InputError as e:
print(f"输入错误: {e}")
except RangeError as e:
print(f"范围错误: {e}")
except BaseError as e:
print(f"基础错误: {e}")

7. 异常链

在Python 3中,可以使用raise ... from ...语法创建异常链,保留原始异常的上下文信息:

7.1 基本用法

try:
withopen("nonexistent.txt","r")as f:
        content = f.read()
except FileNotFoundError as e:
# 创建异常链
raise RuntimeError("文件处理失败")from e

输出:

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    with open("nonexistent.txt", "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'nonexistent.txt'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "example.py", line 6, in <module>
    raise RuntimeError("文件处理失败") from e
RuntimeError: 文件处理失败

7.2 隐式异常链

当在except块中抛出新异常时,如果没有使用from关键字,Python会自动创建隐式异常链:

try:
withopen("nonexistent.txt","r")as f:
        content = f.read()
except FileNotFoundError:
# 隐式异常链
raise RuntimeError("文件处理失败")

输出:

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    with open("nonexistent.txt", "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'nonexistent.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "example.py", line 6, in <module>
    raise RuntimeError("文件处理失败")
RuntimeError: 文件处理失败

7.3 抑制异常链

使用raise ... from None可以抑制异常链:

try:
withopen("nonexistent.txt","r")as f:
        content = f.read()
except FileNotFoundError as e:
# 抑制异常链
raise RuntimeError("文件处理失败")fromNone

输出:

Traceback (most recent call last):
  File "example.py", line 6, in <module>
    raise RuntimeError("文件处理失败") from None
RuntimeError: 文件处理失败

8. 断言

断言(Assertion)是一种调试辅助工具,使用assert语句来检查条件是否为真,如果条件为假,会引发AssertionError异常:

8.1 基本用法

defdivide(a, b):
assert b !=0,"除数不能为零"
return a / b

try:
    result = divide(10,0)
except AssertionError as e:
print(f"断言失败: {e}")

8.2 禁用断言

在运行Python脚本时,可以使用-O选项(优化模式)禁用断言:

python -O example.py  # 断言将被忽略

8.3 断言与异常的区别

  • 断言
    :用于调试,检查程序中的逻辑错误,生产环境中可以禁用
  • 异常
    :用于处理运行时错误,生产环境中必须处理

9. 调试技术

9.1 print()调试

最简单的调试方法是使用print()函数输出变量值:

deffunc(value):
print(f"当前值: {value}")
# 其他代码
return result

9.2 logging模块

使用logging模块可以更灵活地记录调试信息:

import logging

# 配置日志
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s - %(levelname)s - %(message)s')

defdivide(a, b):
    logging.debug(f"a={a}, b={b}")
try:
        result = a / b
        logging.debug(f"结果: {result}")
return result
except ZeroDivisionError as e:
        logging.error(f"错误: {e}")
raise

divide(10,2)
divide(10,0)

9.3 pdb调试器

Python的内置调试器pdb提供了更强大的调试功能:

import pdb

defdivide(a, b):
    pdb.set_trace()# 设置断点
return a / b

result = divide(10,2)
print(f"结果: {result}")

在pdb调试器中,可以使用以下命令:

  • n
    :执行下一行
  • s
    :进入函数
  • c
    :继续执行直到下一个断点
  • l
    :列出当前代码
  • p <变量名>
    :打印变量值
  • q
    :退出调试器

9.4 现代IDE调试

大多数现代Python IDE(如PyCharm、VS Code)都提供了图形化的调试界面,支持断点设置、单步执行、变量查看等功能。

10. 最佳实践

10.1 异常处理的原则

  1. 只捕获特定的异常,避免使用except:捕获所有异常

    # 错误示例
    try:
    # 代码
    except:
    pass# 捕获所有异常,包括KeyboardInterrupt等

    # 正确示例
    try:
    # 代码
    except(ValueError, TypeError)as e:
    # 处理特定异常
    pass
  2. 保持try块尽可能小,只包含可能引发异常的代码

    # 错误示例
    try:
        num1 =int(input("请输入第一个数字: "))
        num2 =int(input("请输入第二个数字: "))
        result = num1 / num2
    print(f"结果: {result}")
    except Exception as e:
    print(f"错误: {e}")

    # 正确示例
    num1 =int(input("请输入第一个数字: "))
    num2 =int(input("请输入第二个数字: "))
    try:
        result = num1 / num2
    except ZeroDivisionError:
    print("错误: 除数不能为零!")
    else:
    print(f"结果: {result}")
  3. 提供有意义的错误信息

    # 错误示例
    try:
    file=open(filename,"r")
    except Exception:
    print("出错了!")

    # 正确示例
    try:
    file=open(filename,"r")
    except FileNotFoundError:
    print(f"错误: 文件 '{filename}' 不存在!")
    except PermissionError:
    print(f"错误: 没有权限读取文件 '{filename}'!")
  4. 不要忽略异常

    # 错误示例
    try:
    # 可能引发异常的代码
    except Exception:
    pass# 忽略异常,隐藏问题

    # 正确示例
    try:
    # 可能引发异常的代码
    except Exception as e:
    # 记录异常并处理
        logging.error(f"发生错误: {e}")
  5. 使用finally清理资源

    # 正确示例
    file=None
    try:
    file=open("example.txt","r")
        content =file.read()
    except FileNotFoundError:
    print("文件不存在!")
    finally:
    iffile:
    file.close()

    # 更好的方式
    withopen("example.txt","r")asfile:
        content =file.read()

10.2 自定义异常的最佳实践

  1. 继承自Exception或其子类

    # 正确示例
    classMyError(Exception):
    pass

    # 更好的方式(继承特定异常类)
    classValidationError(ValueError):
    pass
  2. 提供有意义的异常名称

    # 错误示例
    classError(Exception):
    pass

    # 正确示例
    classDatabaseConnectionError(Exception):
    pass
  3. 添加有用的属性和方法

    classAPIError(Exception):
    def__init__(self, status_code, message):
            self.status_code = status_code
            self.message = message
    super().__init__(f"{status_code}{message}")

10.3 异常处理的常见模式

  1. 重试模式

    import time

    defretry(func, max_retries=3, delay=1):
    for i inrange(max_retries):
    try:
    return func()
    except Exception as e:
    print(f"尝试 {i+1}/{max_retries} 失败: {e}")
                time.sleep(delay)
    raise Exception("超过最大重试次数")

    # 使用重试装饰器
    @retry
    defconnect_to_server():
    # 连接服务器的代码
    pass
  2. 事务模式

    deftransaction(func):
    defwrapper(*args,**kwargs):
    try:
    # 开始事务
                start_transaction()
                result = func(*args,**kwargs)
    # 提交事务
                commit_transaction()
    return result
    except Exception as e:
    # 回滚事务
                rollback_transaction()
    raise
    return wrapper

    @transaction
    defupdate_data():
    # 更新数据库的代码
    pass
  3. 上下文管理器模式

    import contextlib

    @contextlib.contextmanager
    defdatabase_connection():
        connection =None
    try:
            connection = create_connection()
    yield connection
    except Exception as e:
    print(f"数据库操作失败: {e}")
    raise
    finally:
    if connection:
                connection.close()

    # 使用上下文管理器
    with database_connection()as conn:
    # 使用连接执行操作
    pass

11. 总结

错误和异常是Python编程中不可避免的部分,正确处理它们对于编写健壮、可靠的程序至关重要。本文详细介绍了:

  1. 错误与异常的区别
    :语法错误、逻辑错误和异常
  2. 内置异常类型
    :Python提供的丰富异常类层次结构
  3. 异常处理机制
    try-except-else-finally语句的使用
  4. 抛出异常
    :使用raise语句主动抛出异常
  5. 自定义异常
    :创建和使用自己的异常类
  6. 异常链
    :Python 3中的异常链接功能
  7. 断言
    :用于调试的断言语句
  8. 调试技术
    :各种调试方法和工具
  9. 最佳实践
    :异常处理的原则和常见模式

通过学习和掌握这些内容,可以编写出更加健壮、可维护的Python程序,更好地处理各种运行时错误和异常情况。


发布网站:荣殿教程(zhangrongdian.com) 

作者:张荣殿 

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 08:13:22 HTTP/2.0 GET : https://f.mffb.com.cn/a/497517.html
  2. 运行时间 : 0.087938s [ 吞吐率:11.37req/s ] 内存消耗:5,381.42kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=9f10998453cd589ccbe30e02fa2d28e7
  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.000629s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000743s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000338s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000271s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000470s ]
  6. SELECT * FROM `set` [ RunTime:0.000193s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000550s ]
  8. SELECT * FROM `article` WHERE `id` = 497517 LIMIT 1 [ RunTime:0.001020s ]
  9. UPDATE `article` SET `lasttime` = 1783037602 WHERE `id` = 497517 [ RunTime:0.002289s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000310s ]
  11. SELECT * FROM `article` WHERE `id` < 497517 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.002593s ]
  12. SELECT * FROM `article` WHERE `id` > 497517 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000801s ]
  13. SELECT * FROM `article` WHERE `id` < 497517 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002766s ]
  14. SELECT * FROM `article` WHERE `id` < 497517 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002219s ]
  15. SELECT * FROM `article` WHERE `id` < 497517 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001799s ]
0.089380s