当前位置:首页>python>Python模块与包:代码的组织艺术

Python模块与包:代码的组织艺术

  • 2026-03-24 12:55:30
Python模块与包:代码的组织艺术

模块就像工具箱里的一个个工具,包就像装工具的工具箱

🎯 本章目标

学完本章,你会:

  1. ✅ 理解模块和包的概念

  2. ✅ 掌握如何导入和使用模块

  3. ✅ 了解Python标准库

  4. ✅ 学会安装第三方包

  5. ✅ 能创建自己的模块和包

  6. ✅ 理解if __name__ == "__main__"的作用


📁 第一部分:模块 - 代码的"工具箱"

现实比喻

  • 模块 = 一个工具箱 🔧

  • 函数 = 工具箱里的工具

  • 变量 = 工具箱里的零件

  • 类 = 工具箱里的复杂工具

技术定义:模块就是一个.py文件,包含Python定义和语句。

为什么需要模块?

没有模块的世界

# 一个超大的文件,有10000行代码# 前面3000行是数学工具# 中间3000行是字符串处理工具# 后面4000行是文件处理工具# 想找一个函数?翻几千行代码# 想修改一个功能?可能影响其他地方# 和别人合作?文件冲突

有模块的世界

# math_tools.py - 数学工具# string_tools.py - 字符串工具# file_tools.py - 文件工具# 需要哪个工具,导入哪个模块# 清晰、整洁、易维护

🔧 第二部分:使用模块

导入模块的三种方式

方式1:import 模块名

# 导入整个模块import math# 使用模块中的函数result = math.sqrt(16)  # 4.0print(f"16的平方根: {result}")# 使用模块中的变量print(f"圆周率: {math.pi}")  # 3.141592653589793# 使用模块中的函数angle = 45radians = math.radians(angle)  # 角度转弧度print(f"{angle}度 = {radians}弧度")

优点

  • 清晰,知道函数来自哪个模块

  • 避免命名冲突

缺点

  • 每次使用都要写模块名

  • 代码稍长

方式2:from 模块名 import 功能

# 导入特定功能from math import sqrt, pi# 直接使用,不用写模块名result = sqrt(25)  # 5.0print(f"25的平方根: {result}")print(f"圆周率: {pi}")# 导入多个功能from math import sin, cos, tanangle = 30rad = math.radians(angle)print(f"sin({angle}°) = {sin(rad):.2f}")# 导入所有功能(不推荐)# from math import *  # 导入所有,可能造成命名冲突

优点

  • 代码简洁

  • 使用方便

缺点

  • 可能造成命名冲突

  • 不知道函数来自哪里

方式3:给模块起别名

# 给模块起简短的名字import numpy as npimport pandas as pdimport matplotlib.pyplot as plt# 使用# data = pd.read_csv("data.csv")# 这样代码更简洁

🎪 第三部分:Python标准库

Python自带了很多有用的模块,这些就是标准库

常用标准库模块

示例:几个常用模块

# 1. random - 随机数import random# 随机整数dice = random.randint(16)  # 1-6的随机整数print(f"掷骰子: {dice}")# 随机选择colors = ["红""绿""蓝""黄"]lucky_color = random.choice(colors)print(f"幸运颜色: {lucky_color}")# 打乱顺序cards = ["A""K""Q""J""10"]random.shuffle(cards)print(f"洗牌后: {cards}")
# 2. datetime - 日期时间from datetime import datetime, date, timedelta# 当前时间now = datetime.now()print(f"当前时间: {now}")print(f"年: {now.year}, 月: {now.month}, 日: {now.day}")# 格式化时间formatted = now.strftime("%Y年%m月%d日 %H:%M:%S")print(f"格式化: {formatted}")# 计算日期today = date.today()tomorrow = today + timedelta(days=1)print(f"今天: {today}, 明天: {tomorrow}")
# 3. os - 文件操作import os# 获取当前目录current_dir = os.getcwd()print(f"当前目录: {current_dir}")# 列出目录内容# files = os.listdir(".")  # 列出当前目录# for file in files:#     print(file)# 检查文件是否存在if os.path.exists("test.txt"):    print("test.txt 存在")else:    print("test.txt 不存在")
# 4. time - 时间控制import timeprint("开始计时...")time.sleep(1)  # 暂停1秒print("1秒后...")time.sleep(0.5)  # 暂停0.5秒print("又过了0.5秒...")# 计算程序运行时间start = time.time()# 模拟一些操作for i in range(1000000):    passend = time.time()print(f"循环耗时: {end - start:.4f}秒")

🎁 第四部分:安装和使用第三方包

什么是第三方包?

  • Python标准库:Python自带的,不用安装

  • 第三方包:别人写的,需要安装才能用

为什么需要第三方包?

  • 扩展Python功能

  • 避免重复造轮子

  • 有很多优秀的专业包

使用pip安装包;pip是Python的包管理工具,就像手机的"应用商店"。

# 安装包pip install 包名# 安装特定版本pip install 包名==版本号# 升级包pip install --upgrade 包名# 卸载包pip uninstall 包名# 列出已安装的包pip list# 保存包列表到文件pip freeze > requirements.txt# 从文件安装包pip install -r requirements.txt

常用第三方包

示例:使用requests包

# 先安装:pip install requestsimport requests# 发送GET请求response = requests.get("https://api.github.com")print(f"状态码: {response.status_code}")  # 200表示成功print(f"内容类型: {response.headers['content-type']}")# 获取JSON数据if response.status_code == 200:    data = response.json()  # 如果是JSON,转换为字典    print(f"GitHub API版本: {data.get('current_user_url')}")# 发送POST请求(带参数)url = "https://httpbin.org/post"data = {"name""张三""age"25}response = requests.post(url, data=data)print(f"POST响应: {response.json()}")# 下载文件url = "https://www.python.org/static/img/python-logo.png"response = requests.get(url)with open("python_logo.png""wb"as f:    f.write(response.content)print("文件下载完成")

🏗️ 第五部分:创建自己的模块

创建第一个模块

步骤1:创建模块文件

# 保存为 calculator.py# 这是一个计算器模块def add(a, b):    """加法"""    return a + bdef subtract(a, b):    """减法"""    return a - bdef multiply(a, b):    """乘法"""    return a * bdef divide(a, b):    """除法"""    if b == 0:        return "错误:除数不能为0"    return a / b# 模块级别的变量PI = 3.14159VERSION = "1.0.0"

步骤2:使用自己的模块

# 保存为 main.py,和calculator.py在同一个目录import calculator# 使用模块中的函数result1 = calculator.add(105)result2 = calculator.multiply(34)result3 = calculator.divide(102)print(f"10 + 5 = {result1}")print(f"3 × 4 = {result2}")print(f"10 ÷ 2 = {result3}")# 使用模块中的变量print(f"π的值: {calculator.PI}")print(f"版本: {calculator.VERSION}")# 也可以这样导入from calculator import add, subtractprint(f"使用直接导入: 8 - 3 = {subtract(83)}")

添加文档字符串

"""calculator.py这是一个计算器模块,提供基本的数学运算功能。作者: 张三版本: 1.0.0"""def add(a, b):    """    计算两个数的和    参数:    a -- 第一个数    b -- 第二个数    返回:    两个数的和    """    return a + b# 其他函数...

查看模块信息

import calculator# 查看模块文档print(calculator.__doc__)# 查看函数文档print(calculator.add.__doc__)# 查看模块有哪些功能print(dir(calculator))

📦 第六部分:创建包

什么是包?

就是包含多个模块的文件夹。

目录结构

my_package/           # 包目录├── __init__.py       # 包的初始化文件├── module1.py        # 模块1├── module2.py        # 模块2└── subpackage/       # 子包    ├── __init__.py    └── module3.py

创建简单的包

步骤1:创建包结构

my_math/              # 包名├── __init__.py       # 必须有的文件├── basic.py          # 基本运算模块├── advanced.py       # 高级运算模块└── utils.py          # 工具模块

步骤2:编写模块

# my_math/basic.py"""基本数学运算"""def add(a, b):    return a + bdef multiply(a, b):    return a * b# my_math/advanced.py"""高级数学运算"""def power(base, exp):    return base ** expdef factorial(n):    if n == 0:        return 1    return n * factorial(n - 1)# my_math/utils.py"""工具函数"""def is_even(n):    return n % 2 == 0def is_prime(n):    if n < 2:        return False    for i in range(2int(n ** 0.5) + 1):        if n % i == 0:            return False    return True

步骤3:编写init.py

"""my_math 包一个数学工具包"""# 导入包中的模块from .basic import add, multiplyfrom .advanced import power, factorialfrom .utils import is_even, is_prime# 包版本__version__ = "1.0.0"__author__ = "张三"# 可以在这里定义包级别的变量PI = 3.141592653589793E = 2.718281828459045

步骤4:使用包

# 方法1:导入整个包import my_mathprint(f"5 + 3 = {my_math.add(53)}")print(f"5的阶乘 = {my_math.factorial(5)}")print(f"7是质数吗? {my_math.is_prime(7)}")print(f"π = {my_math.PI}")# 方法2:从包中导入特定模块from my_math import basic, advancedprint(f"使用basic模块: 4 × 6 = {basic.multiply(46)}")print(f"使用advanced模块: 2³ = {advanced.power(23)}")# 方法3:从包中导入特定功能from my_math.basic import addfrom my_math.utils import is_evenprint(f"直接导入: 10 + 20 = {add(1020)}")print(f"10是偶数吗? {is_even(10)}")

🎯 第七部分:if __name__ == "__main__"

理解这个魔法语句

问题:当一个模块被导入时,里面的代码都会被执行。

# calculator.pydef add(a, b):    return a + bdef test():    print("测试add函数...")    print(f"2 + 3 = {add(23)}")# 这行代码在导入时也会执行test()  # 问题:别人导入这个模块时,测试代码也会运行

解决方案:使用if __name__ == "__main__"

# calculator.pydef add(a, b):    return a + bdef test():    print("测试add函数...")    print(f"2 + 3 = {add(23)}")# 只有直接运行这个文件时,才会执行if __name__ == "__main__":    test()    print("calculator.py 被直接运行")else:    print(f"calculator.py 被导入为模块,模块名: {__name__}")

__name__变量的值

  1. 文件被直接运行__name__ == "__main__"

  2. 文件被导入__name__ == 模块名

示例

# 文件: my_module.pyprint(f"__name__ 的值是: {__name__}")if __name__ == "__main__":    print("这个文件被直接运行")else:    print("这个文件被导入")# 文件: main.pyimport my_moduleprint("main.py 执行完成")

运行结果

# 直接运行 my_module.py__name__ 的值是: __main__这个文件被直接运行# 运行 main.py__name__ 的值是: my_module这个文件被导入main.py 执行完成

实际应用

# 一个完整的模块示例def add(a, b):    """加法"""    return a + bdef subtract(a, b):    """减法"""    return a - bdef multiply(a, b):    """乘法"""    return a * bdef divide(a, b):    """除法"""    if b == 0:        return "错误:除数不能为0"    return a / bdef run_tests():    """运行测试"""    print("运行测试...")    print(f"测试 add: 5 + 3 = {add(53)}")    print(f"测试 subtract: 10 - 4 = {subtract(104)}")    print(f"测试 multiply: 6 * 7 = {multiply(67)}")    print(f"测试 divide: 15 / 3 = {divide(153)}")    print(f"测试 divide 除零: 5 / 0 = {divide(50)}")    print("测试完成!")def main():    """主函数"""    print("=== 计算器程序 ===")    print("1. 加法")    print("2. 减法")    print("3. 乘法")    print("4. 除法")    choice = input("请选择操作 (1-4): ")    a = float(input("输入第一个数: "))    b = float(input("输入第二个数: "))    if choice == "1":        result = add(a, b)        print(f"结果: {a} + {b} = {result}")    elif choice == "2":        result = subtract(a, b)        print(f"结果: {a} - {b} = {result}")    elif choice == "3":        result = multiply(a, b)        print(f"结果: {a} × {b} = {result}")    elif choice == "4":        result = divide(a, b)        print(f"结果: {a} ÷ {b} = {result}")    else:        print("无效的选择")# 如果是直接运行这个文件,执行主程序# 如果是被导入,不执行主程序if __name__ == "__main__":    main()

🎮 练习时间

练习1:创建自己的模块

任务:创建一个string_utils.py模块包含以下函数:1. reverse_string(s) - 反转字符串2. count_vowels(s) - 统计元音字母数量3. is_palindrome(s) - 判断是否是回文4. 添加测试代码,用if __name__ == "__main__"保护完成后,创建另一个文件main.py,导入并使用这个模块

练习2:安装和使用第三方包

# 任务:安装colorama包,让终端输出有颜色# 1. pip install colorama# 2. 使用colorama输出彩色文本# 3. 创建一个彩色日志系统from colorama import init, Fore, Back, Styleinit(autoreset=True)  # 自动重置颜色print(Fore.RED + "这是红色文字")print(Back.GREEN + "这是绿色背景")print(Style.BRIGHT + "这是加粗文字")

练习3:理解模块导入

# 文件结构:# project/#   ├── utils/#   │   ├── __init__.py#   │   ├── math_utils.py#   │   └── string_utils.py#   └── main.py# 任务:在math_utils.py中定义一些数学函数# 在string_utils.py中定义一些字符串函数# 在main.py中导入并使用它们# 理解相对导入和绝对导入

💡 常见错误

错误1:模块找不到

# ❌ 错误import mymodule # ModuleNotFoundError: No module named 'mymodule'# ✅ 解决方法:# 1. 确保模块文件在当前目录# 2. 确保模块文件是.py文件# 3. 检查文件名拼写

错误2:循环导入

# ❌ 错误:a.py 导入 b.pyb.py 又导入 a.pya.pyimport bb.pyimport a  # 循环导入,可能导致错误# ✅ 解决方法:# 重新设计代码结构,避免循环导入

错误3:包缺少init.py

# ❌ 错误my_package/    module1.py    module2.py# 缺少__init__.py,Python不认为这是包# ✅ 解决方法:# 添加空的__init__.py文件

错误4:导入顺序问题

# ❌ 不推荐的导入顺序import sysimport osfrom mymodule import somethingimport math  # 标准库应该在最前面# ✅ 推荐的导入顺序:# 1. 标准库# 2. 第三方库# 3. 自己的模块import mathimport osimport sysimport requestsimport pandasfrom mymodule import something

📊 模块和包总结


📋 检查清单

  • [ ] 能导入和使用标准库模块

  • [ ] 能安装第三方包

  • [ ] 能创建自己的模块

  • [ ] 能创建包(包含init.py)

  • [ ] 理解if __name__ == "__main__"的作用

  • [ ] 能正确组织导入语句

  • [ ] 能为模块写文档字符串

  • [ ] 能使用pip管理包

  • [ ] 能看懂别人的模块结构

  • [ ] 能处理常见的模块错误


🎉 恭喜!模块和包掌握完成现在你已经学会了如何组织Python代码:

关键收获

  1. ✅ 模块:把代码分到不同文件

  2. ✅ :把模块分到不同文件夹

  3. ✅ 导入:使用别人的代码

  4. ✅ 标准库:Python自带的工具

  5. ✅ 第三方包:扩展Python功能

  6. ✅ 创建模块:分享自己的代码

现在你可以

  • 把大项目拆分成小模块

  • 使用丰富的Python生态系统

  • 安装和使用专业工具

  • 创建可重用的代码库

  • 更好地组织测试代码

下一章预告:文件操作 - 读写数据

你会学习如何读取和写入文件,处理各种格式的数据,这是自动化测试的重要技能!

准备好了吗?让我们继续前进!🚀

小提示:模块和包就像乐高积木,小的模块组合成大的系统。先学会用别人的"积木",再学会做自己的"积木",最后就能搭建复杂的"建筑"了!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 09:52:19 HTTP/2.0 GET : https://f.mffb.com.cn/a/479707.html
  2. 运行时间 : 0.200883s [ 吞吐率:4.98req/s ] 内存消耗:4,904.88kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=00be4d841e513a39e6ed06304b1c8e03
  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.000741s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000811s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001791s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000335s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000695s ]
  6. SELECT * FROM `set` [ RunTime:0.001300s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000704s ]
  8. SELECT * FROM `article` WHERE `id` = 479707 LIMIT 1 [ RunTime:0.014227s ]
  9. UPDATE `article` SET `lasttime` = 1774576339 WHERE `id` = 479707 [ RunTime:0.029688s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000974s ]
  11. SELECT * FROM `article` WHERE `id` < 479707 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.002033s ]
  12. SELECT * FROM `article` WHERE `id` > 479707 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001244s ]
  13. SELECT * FROM `article` WHERE `id` < 479707 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001688s ]
  14. SELECT * FROM `article` WHERE `id` < 479707 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.003866s ]
  15. SELECT * FROM `article` WHERE `id` < 479707 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.004574s ]
0.203770s