当前位置:首页>python>【从零开始学Python】篇10-基础语法章-模块和包

【从零开始学Python】篇10-基础语法章-模块和包

  • 2026-06-30 19:01:13
【从零开始学Python】篇10-基础语法章-模块和包

前面的文章我们学了数据类型、运算、三大结构、函数、文件操作、异常处理,你已经能写不少实用的程序了。

但你有没有遇到过这样的问题:

  • 一个文件写了上千行代码,自己都不想翻

  • 想复用之前写的功能,只能复制粘贴

  • 不知道别人写的库怎么导入使用

  • 自己的项目文件越放越多,找不到谁是谁

这时候,你就需要模块和包了!


一、什么是模块?

模块 = 一个 .py 文件

简单来说,你写的每一个 .py 文件,都是一个模块。

# calc.py —— 这就是一个模块def add(a, b):    return a + bdef multiply(a, b):    return a * bPI =3.14159

模块的好处:1️⃣ 把相关功能的代码放在一起2️⃣ 可以被其他程序导入使用3️⃣ 避免命名冲突4️⃣ 方便维护和复用


二、什么是包?

包 = 一个包含多个模块的文件夹

当一个项目有多个模块时,用包来组织它们:

my_package/              # 包(文件夹)    

    __init__.py          # 包的标识文件    

    math_utils.py        # 模块1    

    string_utils.py      # 模块2    

    file_utils.py        # 模块3

__init__.py 告诉Python这是一个包。在Python 3.3+ 中可以为空,甚至可省略,但保留是好习惯。


三、导入模块的5种方式

1️⃣ 直接导入整个模块

import mathprint(math.sqrt(16))# 4.0print(math.pi)# 3.14159...

2️⃣ 给模块起别名

import numpy as npimport pandas as pd# 常见缩写arr = np.array([1,2,3])

3️⃣ 导入模块中的特定部分

from math import sqrt, piprint(sqrt(25))# 5.0,不用写 math.print(pi)# 3.14159

4️⃣ 导入所有内容(不推荐)

from math import *# ⚠️ 风险:可能会覆盖你定义的函数print(sqrt(100))

5️⃣ 导入并重命名

from math import sqrt as square_rootprint(square_root(144))# 12.0

四、导入自己写的模块

假设你写了 calc.py

# calc.pydef add(a, b):    return a + bdef subtract(a, b):    return a - bPI =3.14159

在同一个文件夹下创建 main.py 导入它:

# main.pyimport calcprint(calc.add(5,3))# 8print(calc.subtract(5,3))# 2print(calc.PI)# 3.14159

或者用 from...import

from calc import add, PIprint(add(10,20))# 30print(PI)# 3.14159

五、创建和使用包

包的结构示例

my_project/│
├── main.py│
└── utils/                  
# 包   
├── __init__.py   
├── math_utils.py   
 └── string_utils.py
math_utils.py
def add(a, b):    return a + b def multiply(a, b):    return a * b

string_utils.py

def reverse(s):    return s[::-1]def to_upper(s):    return s.upper()

__init__.py(可以暴露常用接口)

# 让外部导入更方便from .math_utils import add, multiplyfrom .string_utils import reverse, to_upper__all__ =['add','multiply','reverse','to_upper']

main.py 中使用包

# 方式1:导入整个包import utilsprint(utils.add(3,5))# 8print(utils.reverse("hello"))# olleh# 方式2:导入特定函数from utils import multiply, to_upperprint(multiply(4,5))# 20print(to_upper("hello"))# HELLO# 方式3:直接导入模块from utils import math_utilsprint(math_utils.add(10,20))

六、常用内置模块(拿来就用)

Python自带很多好用的模块,直接 import 就行:

1️⃣ random —— 随机数

import random# 随机整数num = random.randint(1,10)# 1-10# 随机浮点数num2 = random.random()# 0-1# 随机选择choice = random.choice(["苹果","香蕉","橙子"])# 打乱列表cards =[1,2,3,4,5]random.shuffle(cards)

2️⃣ datetime —— 日期时间

from datetime import datetime, timedelta# 当前时间now = datetime.now()print(now.strftime("%Y-%m-%d%H:%M:%S"))# 计算日期tomorrow = now + timedelta(days=1)yesterday = now - timedelta(days=1)

3️⃣ os —— 操作系统交互

import os# 当前目录cur = os.getcwd()# 列出文件files = os.listdir(".")# 创建目录os.mkdir("new_folder")# 路径拼接path = os.path.join("folder","file.txt")

4️⃣ sys —— Python解释器相关

import sys# 命令行参数print(sys.argv)# Python版本print(sys.version)# 退出程序sys.exit(0)

5️⃣ json —— JSON数据处理

import json# 字典转JSON字符串data ={"name":"小明","age":18}json_str = json.dumps(data, ensure_ascii=False)# JSON字符串转字典obj = json.loads('{"name""张三"}')

6️⃣ re —— 正则表达式

import re# 匹配手机号phone ="13812345678"if re.match(r'^1[3-9]\d{9}$', phone):    print("手机号合法")

七、第三方模块的安装和使用

Python有一个巨大的第三方库生态,需要通过 pip 安装。

安装第三方模块

# 基础安装pip install requests# 指定版本pip installrequests==2.28.0# 升级pip install--upgrade requests# 卸载pip uninstall requests# 查看已安装的模块pip list
常用第三方模块推荐
模块
用途
requests
网络请求
numpy
科学计算
pandas
数据分析
flask
 / django
Web开发
pillow
图片处理
pytest
单元测试
beautifulsoup4
网页解析
selenium
自动化测试

示例:使用 requests 获取网页

import requests# 发送GET请求response = requests.get("https://api.github.com")# 检查状态码if response.status_code ==200:    data = response.json()    # 解析JSON    print(data)else:    print(f"请求失败:{response.status_code}")

八、模块搜索路径

当你在写 import xxx 时,Python会按以下顺序找模块:

import sysprint(sys.path)

搜索顺序:

  1. 当前文件所在目录

  2. PYTHONPATH 环境变量中的目录

  3. Python安装目录下的标准库

  4. 第三方库安装目录(site-packages)

添加自定义搜索路径

import syssys.path.append("/path/to/your/module")# 现在可以导入了import your_module

九、if __name__ == "__main__" 的妙用

这是一个非常重要的Python约定:

# my_module.pydef add(a, b):    return a + bdef main():    # 测试代码    print("测试加法:", add(3,5))if __name__ =="__main__":        main()

作用:

  • 直接运行 python my_module.py → 执行 main()(测试用)

  • 在其他地方 import my_module → 不会执行 main()(只导入功能)

这是用来区分“作为脚本运行”和“作为模块导入”的标准写法。


十、实战案例

案例1:自定义工具模块

创建 my_tools.py

"""我的工具函数集合"""import randomfrom datetime import datetimedef generate_code(length=6):    """生成随机验证码(数字+字母)"""        chars ='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'    return''.join(random.choice(chars)    for _ in range(length)) def get_today_str(format_str="%Y-%m-%d"):    """获取今天的日期字符串"""    return datetime.now().strftime(format_str) def safe_divide(a, b):     """安全除法"""     try:       return a / b     except ZeroDivisionError:         return float('inf')     except TypeError:     return Noneif __name__ =="__main__":    # 测试代码    print("验证码:", generate_code())    print("今天:", get_today_str())    print("10/0 =", safe_divide(10,0))

使用它:

import my_toolscode = my_tools.generate_code()print(f"您的验证码是:{code}")

案例2:创建自己的包

my_utils/├
── __init__.py
├── file_utils.py
└── network_utils.py
file_utils.py
import json import os def read_json(filepath):    """读取JSON文件"""    with open(filepath,'r', encoding='utf-8')as f:        return json.load(f)def write_json(filepath, data):    """写入JSON文件"""    with open(filepath,'w', encoding='utf-8')as f:            json.dump(data, f, indent=4, ensure_ascii=False)def ensure_dir(dirpath):    """确保目录存在"""        os.makedirs(dirpath, exist_ok=True)

network_utils.py

import requestsdef fetch_url(url, timeout=10):    """获取网页内容"""    try:        resp = requests.get(url, timeout=timeout)        resp.raise_for_status()        return resp.text    except requests.RequestException as e:        print(f"请求失败:{e}")        return None

__init__.py

from.file_utils import read_json, write_json, ensure_dirfrom.network_utils import fetch_url__all__ =['read_json','write_json','ensure_dir','fetch_url']

使用包:

from my_utils import read_json, ensure_dir, fetch_url# 确保目录存在ensure_dir("./data")# 读取配置config = read_json("./config.json")# 获取网页html = fetch_url("https://www.example.com")

案例3:使用 pip 管理项目依赖

创建 requirements.txt

requests>=2.28.0pandas==1.5.0numpy<1.24.0

批量安装:

pip install-r requirements.txt

导出当前环境的所有依赖:

pip freeze > requirements.txt

十一、常见错误与避坑指南

🔥 坑1:循环导入

# a.pyimport b def func_a():    b.func_b()# b.pyimport a def func_b():        a.func_a()

两个模块互相导入,会导致出错。设计时应避免循环依赖。

🔥 坑2:模块名和内置模块重名

# ❌ 不要创建 math.py、random.py 这样的文件# 会覆盖Python的内置模块# ✅ 取有意义的名字# my_math.py、my_random.py

🔥 坑3:忘记写 __init__.py

# 如果包文件夹没有 __init__.pyimport my_package  # ❌ 可能报错# Python 3.3+ 不强制要求,但推荐保留

🔥 坑4:相对导入报错

# 在普通脚本中不能用 . 开头的相对导入# ❌ 直接运行时会报错from.module import func# ✅ 使用绝对导入from my_package.module import func

十二、速查表

需求
代码
导入整个模块
import math
导入并起别名
import numpy as np
导入特定函数
from math import sqrt
导入所有
from math import *
(不推荐)
创建包
建文件夹 + __init__.py
查看模块路径
import sys; print(sys.path)
脚本/模块两用
if __name__ == "__main__":
安装第三方库
pip install 包名
导出依赖列表
pip freeze > requirements.txt
安装依赖列表
pip install -r requirements.txt

写在最后

模块和包是Python工程化的基石。

掌握了它们,你就能:

  • 写出更清晰的代码结构

  • 复用自己和他人的代码

  • 参与更大的项目开发


📌 如果觉得有用,点赞+在看+转发 给正在学Python的小伙伴!

模块化编程,让代码更优雅。我们下期见! 👋

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 19:31:00 HTTP/2.0 GET : https://f.mffb.com.cn/a/494226.html
  2. 运行时间 : 0.093997s [ 吞吐率:10.64req/s ] 内存消耗:4,588.00kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=cfe86d304a353b52ae3927d5657bc05e
  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.000373s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000642s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.003312s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000286s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000485s ]
  6. SELECT * FROM `set` [ RunTime:0.003251s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000587s ]
  8. SELECT * FROM `article` WHERE `id` = 494226 LIMIT 1 [ RunTime:0.000686s ]
  9. UPDATE `article` SET `lasttime` = 1783078260 WHERE `id` = 494226 [ RunTime:0.010977s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000263s ]
  11. SELECT * FROM `article` WHERE `id` < 494226 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000449s ]
  12. SELECT * FROM `article` WHERE `id` > 494226 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.003318s ]
  13. SELECT * FROM `article` WHERE `id` < 494226 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.000784s ]
  14. SELECT * FROM `article` WHERE `id` < 494226 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000649s ]
  15. SELECT * FROM `article` WHERE `id` < 494226 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001342s ]
0.095544s