当前位置:首页>python>Python 零基础100天—Day31 os 与 pathlib

Python 零基础100天—Day31 os 与 pathlib

  • 2026-06-28 12:24:45
Python 零基础100天—Day31 os 与 pathlib

🐍 os 与 pathlib — 文件目录操作一把梭

🕐 预计用时:2-3 小时 | 🎯 目标:掌握文件/目录操作、路径处理、遍历目录、环境变量


📖 今日目录

  1. os 模块基础 — 系统信息与当前目录
  2. 文件操作 — 重命名、删除、获取信息
  3. 目录操作 — 创建、删除、切换
  4. os.path 路径处理 — 拼接、判断、获取大小
  5. 遍历目录 — os.walk 与 os.scandir
  6. pathlib 入门 — 现代路径操作
  7. pathlib 常用操作 — exists/glob/mkdir/rename
  8. pathlib 读写文件 — read_text/write_text
  9. 环境变量 — os.environ 与 os.getenv
  10. 实战:批量文件统计工具 + 目录清理器
  11. os vs pathlib 对比与选型
  12. 今日小结

1. os 模块基础 — 系统信息与当前目录

os 模块是 Python 与操作系统交互的桥梁——文件、目录、环境变量、进程,全靠它。

import os

# 操作系统类型
print(os.name)            # 'posix' (Linux/Mac) 或 'nt' (Windows)

# 当前工作目录
print(os.getcwd())        # /root/.openclaw/workspace

# 列出当前目录下的文件和文件夹
print(os.listdir())       # ['students.csv', 'config.json', 'output.csv', ...]

# 列出指定目录
print(os.listdir("/tmp"))  # ['openclaw', 'video.mp4', ...]

系统信息

import os

# 环境变量中的路径
print(os.environ.get("HOME"))    # /root
print(os.environ.get("PATH"))    # /usr/local/sbin:/usr/local/bin:...

# 当前用户名
print(os.getlogin())              # root

# 当前进程 ID
print(os.getpid())                # 12345

# 路径分隔符(Windows 是 \,Linux/Mac 是 /)
print(os.sep)                     # /

# 路径分隔符(Windows 是 ;,Linux/Mac 是 :)
print(os.pathsep)                 # :

💡 os.name vs platform 模块:
os.name 只返回 'posix'/'nt'/'java',更详细的系统信息用 platform 模块:
import platform; print(platform.system()) → 'Linux'/'Windows'/'Darwin'


2. 文件操作 — 重命名、删除、获取信息

重命名与删除

import os

# 先创建一个测试文件
with open("test_file.txt", "w") as f:
    f.write("Hello, os module!")

# 重命名文件
os.rename("test_file.txt", "renamed.txt")
print("重命名完成")  # test_file.txt → renamed.txt

# 删除文件
os.remove("renamed.txt")  # 或 os.unlink("renamed.txt")
print("删除完成")

# ⚠️ 删除不存在的文件会报 FileNotFoundError
# os.remove("not_exist.txt")  # FileNotFoundError

安全删除(先检查再删)

import os

def safe_remove(filepath):
    """安全删除文件"""
    if os.path.exists(filepath):
        os.remove(filepath)
        print(f"✅ 已删除: {filepath}")
    else:
        print(f"⚠️ 文件不存在: {filepath}")

safe_remove("not_exist.txt")   # ⚠️ 文件不存在: not_exist.txt
safe_remove("some_file.txt")   # ✅ 已删除: some_file.txt

获取文件信息

import os
from datetime import datetime

# 创建测试文件
with open("info_test.txt", "w") as f:
    f.write("Hello World!")

# 获取文件状态信息
stat = os.stat("info_test.txt")

print(f"文件大小: {stat.st_size} 字节")        # 12
print(f"创建时间: {datetime.fromtimestamp(stat.st_ctime)}")
print(f"修改时间: {datetime.fromtimestamp(stat.st_mtime)}")
print(f"访问时间: {datetime.fromtimestamp(stat.st_atime)}")

# 简写:只获取大小
print(f"大小: {os.path.getsize('info_test.txt')} 字节")  # 12

# 判断类型
print(os.path.isfile("info_test.txt"))   # True(是文件)
print(os.path.isdir("info_test.txt"))    # False(不是目录)

os.remove("info_test.txt")

3. 目录操作 — 创建、删除、切换

创建目录

import os

# 创建单层目录
os.mkdir("test_dir")
print("创建目录 test_dir")

# 创建多层嵌套目录
os.makedirs("parent/child/grandchild", exist_ok=True)
print("创建嵌套目录 parent/child/grandchild")

# exist_ok=True 表示目录已存在时不报错
os.makedirs("parent/child/grandchild", exist_ok=True)  # 不报错

# ❌ 不加 exist_ok,目录已存在会报错
# os.makedirs("parent/child/grandchild")  # FileExistsError

删除目录

import os

# 删除空目录
os.rmdir("test_dir")
print("删除空目录 test_dir")

# 删除多层空目录(从内到外)
os.removedirs("parent/child/grandchild")
print("删除嵌套目录")

# ⚠️ rmdir 只能删空目录,目录非空会报错
# os.rmdir("some_dir_with_files")  # OSError: Directory not empty

切换与创建临时目录

import os
import tempfile

# 切换工作目录
original_dir = os.getcwd()
os.chdir("/tmp")
print(f"切换到: {os.getcwd()}")
os.chdir(original_dir)  # 切回来

# 获取用户的 home 目录
home = os.path.expanduser("~")
print(f"Home: {home}")  # /root

# 创建临时目录
tmp_dir = tempfile.mkdtemp()
print(f"临时目录: {tmp_dir}")  # /tmp/tmpXXXXXX

# 用完清理
os.rmdir(tmp_dir)

4. os.path 路径处理 — 拼接、判断、获取大小

os.path 是路径处理的瑞士军刀——拼接、拆分、判断存在性,全在这。

路径拼接

import os

# ❌ 错误做法:字符串拼接(跨平台会出问题)
path = "/home/user" + "/" + "file.txt"  # Linux 可以,Windows 不行

# ✅ 正确做法:os.path.join
path = os.path.join("/home", "user", "file.txt")
print(path)  # /home/user/file.txt

# Windows 上会自动用反斜杠:
# C:\Users\user\file.txt

路径拆分

import os

path = "/home/user/documents/report.pdf"

# 获取目录部分
print(os.path.dirname(path))     # /home/user/documents

# 获取文件名部分
print(os.path.basename(path))    # report.pdf

# 同时获取目录和文件名
dir_part, file_part = os.path.split(path)
print(f"目录: {dir_part}")        # 目录: /home/user/documents
print(f"文件: {file_part}")       # 文件: report.pdf

# 分离扩展名
name, ext = os.path.splitext("report.pdf")
print(f"名称: {name}")    # 名称: report
print(f"扩展名: {ext}")    # 扩展名: .pdf

# 获取文件名不含扩展名
print(os.path.splitext(os.path.basename(path))[0])  # report

路径判断

import os

# 判断路径是否存在
print(os.path.exists("/root"))          # True
print(os.path.exists("/not_exist"))     # False

# 判断是文件还是目录
print(os.path.isfile("/root/.bashrc"))  # True(文件)
print(os.path.isdir("/root"))           # True(目录)

# 判断是否是绝对路径
print(os.path.isabs("/home/user"))      # True
print(os.path.isabs("relative/path"))   # False

# 获取绝对路径
print(os.path.abspath("."))             # /root/.openclaw/workspace
print(os.path.abspath("test.txt"))      # /root/.openclaw/workspace/test.txt

文件大小

import os

def get_size(path):
    """获取文件或目录的大小"""
    if os.path.isfile(path):
        size = os.path.getsize(path)
    elif os.path.isdir(path):
        size = sum(
            os.path.getsize(os.path.join(dirpath, f))
            for dirpath, dirnames, filenames in os.walk(path)
            for f in filenames
        )
    else:
        return 0

    # 人类友好的大小
    for unit in ['B', 'KB', 'MB', 'GB']:
        if size < 1024:
            return f"{size:.1f} {unit}"
        size /= 1024
    return f"{size:.1f} TB"

print(get_size("/root/.openclaw/workspace"))  # 例如: 15.3 MB

💡 os.path 速查表:
join(a, b)→ 拼接路径
dirname(path)→ 目录部分
basename(path)→ 文件名部分
splitext(path)→ (名称, 扩展名)
exists(path)→ 是否存在
isfile(path)→ 是否是文件
isdir(path)→ 是否是目录
getsize(path) → 文件大小(字节)


5. 遍历目录 — os.walk 与 os.scandir

遍历目录是最常用的操作之一——统计文件、搜索特定文件、批量处理。

os.walk — 递归遍历(最常用)

import os

# os.walk 生成三元组: (当前目录路径, 子目录列表, 文件列表)
for dirpath, dirnames, filenames in os.walk("/root/.openclaw/workspace"):
    print(f"\n📂 {dirpath}")

    for dirname in dirnames:
        print(f"  📁 [目录] {dirname}")

    for filename in filenames:
        filepath = os.path.join(dirpath, filename)
        size = os.path.getsize(filepath)
        print(f"  📄 {filename} ({size} bytes)")

    # 只遍历前2层(防止输出太多)
    if dirpath.count(os.sep) - "/root/.openclaw/workspace".count(os.sep) >= 2:
        break

实战:统计目录中的文件类型

import os
from collections import Counter

def count_file_types(root_dir):
    """统计目录下各类型的文件数量"""
    ext_counter = Counter()
    total_size = 0

    for dirpath, dirnames, filenames in os.walk(root_dir):
        for f in filenames:
            filepath = os.path.join(dirpath, f)
            name, ext = os.path.splitext(f)
            ext_counter[ext.lower()] += 1
            total_size += os.path.getsize(filepath)

    print(f"📊 目录统计: {root_dir}")
    print(f"   总文件数: {sum(ext_counter.values())}")
    print(f"   总大小: {total_size / 1024 / 1024:.2f} MB")
    print(f"   文件类型分布:")
    for ext, count in ext_counter.most_common(10):
        print(f"     {ext or '(无扩展名)'}: {count} 个")

count_file_types("/root/.openclaw/workspace")

os.scandir — 非递归扫描(更快)

import os

# scandir 比 listdir 更高效(减少系统调用)
with os.scandir("/root/.openclaw/workspace") as entries:
    for entry in entries:
        if entry.is_file():
            print(f"📄 {entry.name} ({entry.stat().st_size} bytes)")
        elif entry.is_dir():
            print(f"📁 {entry.name}/")

⚠️ os.walk vs os.scandir:
• os.walk → 递归遍历所有子目录(找所有文件)
• os.scandir → 只看当前一层(速度快,不递归)
• 只需当前目录 → scandir;需要所有子目录 → walk

6. pathlib 入门 — 现代路径操作

pathlib 是 Python 3.4+ 引入的现代路径库——用面向对象的方式操作路径,比 os.path 更优雅。

from pathlib import Path

# 创建 Path 对象
p = Path("/home/user/documents/report.pdf")

# 属性访问(比 os.path 更直观)
print(p.name)       # report.pdf(文件名)
print(p.stem)       # report(不含扩展名)
print(p.suffix)     # .pdf(扩展名)
print(p.parent)     # /home/user/documents(父目录)
print(p.parents[0]) # /home/user/documents
print(p.parents[1]) # /home/user
print(p.parts)      # ('/', 'home', 'user', 'documents', 'report.pdf')

# 当前目录和 home 目录
print(Path.cwd())   # /root/.openclaw/workspace
print(Path.home())  # /root

路径拼接 — 用 / 运算符

from pathlib import Path

# ✅ 用 / 拼接路径(比 os.path.join 更优雅)
base = Path("/home/user")
filepath = base / "documents" / "report.pdf"
print(filepath)  # /home/user/documents/report.pdf

# 也可以用 /
doc_dir = Path.home() / "Documents"
print(doc_dir)   # /root/Documents

# 拼接文件名
project = Path("/project")
for name in ["main.py", "utils.py", "config.json"]:
    print(project / "src" / name)
# /project/src/main.py
# /project/src/utils.py
# /project/src/config.json

💡 pathlib 的最大优势:用 / 运算符拼接路径,比 os.path.join() 更直观、更 Pythonic!


7. pathlib 常用操作 — exists/glob/mkdir/rename

判断与查询

from pathlib import Path

p = Path("/root/.bashrc")

# 判断存在性
print(p.exists())     # True
print(p.is_file())    # True
print(p.is_dir())     # False
print(p.is_absolute()) # True

# 文件大小
print(p.stat().st_size)  # 文件大小(字节)

# 获取匹配的文件
py_files = list(Path("/root/.openclaw/workspace").glob("*.py"))
print(f"Python 文件: {py_files}")

glob 模式匹配

from pathlib import Path

workspace = Path("/root/.openclaw/workspace")

# glob() — 当前目录匹配
for p in workspace.glob("*.md"):
    print(f"📄 {p.name}")
# 📄 MEMORY.md
# 📄 USER.md
# 📄 SOUL.md
# ...

# rglob() — 递归匹配所有子目录
for p in workspace.rglob("*.html"):
    print(f"📄 {p.relative_to(workspace)}")
# Python-100天/day01.html
# Python-100天/day02.html
# ...

# 通配符模式
for p in workspace.glob("**/*.py"):  # 等价于 rglob
    print(p)

# 匹配特定模式
for p in workspace.glob("day[0-9]*.html"):
    print(p.name)

创建与重命名

from pathlib import Path

# 创建目录
Path("new_dir").mkdir(exist_ok=True)

# 创建多层目录
Path("a/b/c").mkdir(parents=True, exist_ok=True)

# 创建文件
Path("new_file.txt").touch()

# 重命名
Path("new_file.txt").rename("renamed_file.txt")

# 删除文件
Path("renamed_file.txt").unlink()  # unlink() = remove()

# 删除空目录
Path("new_dir").rmdir()

# 删除目录树(递归删除,危险!)
import shutil
shutil.rmtree("a")  # 删除整个 a/ 目录

8. pathlib 读写文件 — read_text/write_text

pathlib 可以直接读写文件,不需要 open()——简洁到令人发指。

from pathlib import Path

# 写入文本文件
p = Path("demo.txt")
p.write_text("Hello, pathlib!", encoding="utf-8")

# 读取文本文件
content = p.read_text(encoding="utf-8")
print(content)  # Hello, pathlib!

# 写入二进制文件
p_bin = Path("demo.bin")
p_bin.write_bytes(b"\x00\x01\x02\x03")

# 读取二进制文件
data = p_bin.read_bytes()
print(data)  # b'\x00\x01\x02\x03'

# 追加内容(pathlib 没有 append 方法,用 open)
with p.open("a", encoding="utf-8") as f:
    f.write("\nAppended line!")

# 清理
p.unlink()
p_bin.unlink()

对比:pathlib vs os.path 读写文件

from pathlib import Path

# ---- 旧方式 (os.path) ----
import os
filepath = os.path.join("/tmp", "test.txt")
with open(filepath, "w", encoding="utf-8") as f:
    f.write("Hello")
with open(filepath, "r", encoding="utf-8") as f:
    content = f.read()

# ---- 新方式 (pathlib) ----
filepath = Path("/tmp") / "test.txt"
filepath.write_text("Hello", encoding="utf-8")
content = filepath.read_text(encoding="utf-8")

# pathlib 少了 3 行代码!

💡 pathlib 读写适合小文件,大文件还是用 open() + with 语句,因为 pathlib 的 read_text() 会一次性加载全部内容到内存。


9. 环境变量 — os.environ 与 os.getenv

环境变量是程序配置的重要来源——数据库密码、API Key、运行环境等敏感信息不写死在代码里。

import os

# 获取所有环境变量
for key, value in os.environ.items():
    if key.startswith("HOME") or key.startswith("PATH"):
        print(f"{key} = {value[:80]}...")  # 只显示前80字符

# 获取单个环境变量
home = os.environ.get("HOME")         # 不存在返回 None
path = os.environ.get("PATH")         # PATH 环境变量
shell = os.environ.get("SHELL")       # /bin/bash

# 获取环境变量(带默认值)
db_host = os.environ.get("DB_HOST", "localhost")
db_port = int(os.environ.get("DB_PORT", "3306"))
debug = os.environ.get("DEBUG", "false").lower() == "true"

print(f"DB: {db_host}:{db_port}, Debug: {debug}")

设置环境变量

import os

# 在当前进程中设置环境变量
os.environ["MY_APP_MODE"] = "development"
os.environ["MY_APP_PORT"] = "8080"

# 验证
print(os.environ["MY_APP_MODE"])  # development

# 删除环境变量
del os.environ["MY_APP_MODE"]

# 检查是否存在
print("MY_APP_MODE" in os.environ)  # False

实战:配置管理

import os

class Config:
    """从环境变量读取配置"""

    def __init__(self):
        self.DEBUG = os.getenv("DEBUG", "false").lower() == "true"
        self.DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///app.db")
        self.SECRET_KEY = os.getenv("SECRET_KEY", "dev-secret-key")
        self.PORT = int(os.getenv("PORT", "5000"))
        self.LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")

    def __repr__(self):
        return f"Config(debug={self.DEBUG}, port={self.PORT})"

config = Config()
print(config)  # Config(debug=False, port=5000)

⚠️ 安全提示:不要把 API Key、数据库密码等硬编码在代码中!用环境变量或 .env 文件管理敏感配置。
推荐用 python-dotenv 库从 .env 文件加载环境变量。


10. 实战:批量文件统计工具 + 目录清理器

批量文件统计工具

import os
from pathlib import Path
from collections import Counter, defaultdict
from datetime import datetime

def file_stats(root_dir):
    """生成目录的详细统计报告"""
    root = Path(root_dir)

    if not root.exists():
        print(f"❌ 目录不存在: {root_dir}")
        return

    ext_counter = Counter()
    ext_sizes = defaultdict(int)
    total_files = 0
    total_dirs = 0
    total_size = 0
    oldest_file = None
    newest_file = None

    for dirpath, dirnames, filenames in os.walk(root):
        total_dirs += len(dirnames)

        for f in filenames:
            filepath = Path(dirpath) / f
            try:
                stat = filepath.stat()
                size = stat.st_size
                mtime = stat.st_mtime
            except (OSError, PermissionError):
                continue

            total_files += 1
            total_size += size

            ext = filepath.suffix.lower()
            ext_counter[ext] += 1
            ext_sizes[ext] += size

            if oldest_file is None or mtime < oldest_file[1]:
                oldest_file = (str(filepath), mtime)
            if newest_file is None or mtime > newest_file[1]:
                newest_file = (str(filepath), mtime)

    # 输出报告
    print("=" * 50)
    print(f"📊 目录统计报告: {root_dir}")
    print("=" * 50)
    print(f"📁 目录总数: {total_dirs}")
    print(f"📄 文件总数: {total_files}")
    print(f"💾 总大小: {total_size / 1024 / 1024:.2f} MB")

    if oldest_file:
        print(f"📅 最旧文件: {oldest_file[0]} ({datetime.fromtimestamp(oldest_file[1])})")
    if newest_file:
        print(f"📅 最新文件: {newest_file[0]} ({datetime.fromtimestamp(newest_file[1])})")

    print(f"\n📋 文件类型 TOP 10:")
    for ext, count in ext_counter.most_common(10):
        size_mb = ext_sizes[ext] / 1024 / 1024
        print(f"  {ext or '(无扩展名)':12s}  {count:4d} 个  {size_mb:8.2f} MB")

# 使用
file_stats("/root/.openclaw/workspace")

目录清理器

import os
import time
from pathlib import Path

def cleanup_old_files(directory, days=30, dry_run=True):
    """清理超过指定天数的文件"""
    target = Path(directory)
    cutoff = time.time() - (days * 86400)
    removed = []

    for filepath in target.rglob("*"):
        if not filepath.is_file():
            continue

        mtime = filepath.stat().st_mtime
        if mtime < cutoff:
            size = filepath.stat().st_size
            age_days = int((time.time() - mtime) / 86400)

            if dry_run:
                print(f"🔍 [模拟] 将删除: {filepath.name} ({age_days}天前, {size}B)")
            else:
                filepath.unlink()
                print(f"🗑️ 已删除: {filepath.name}")

            removed.append(str(filepath))

    print(f"\n{'模拟' if dry_run else '实际'}清理: {len(removed)} 个文件")
    return removed

# 先模拟运行(不实际删除)
cleanup_old_files("/tmp", days=7, dry_run=True)

# 确认后实际删除
# cleanup_old_files("/tmp", days=7, dry_run=False)

11. os vs pathlib 对比与选型

操作
os / os.path
pathlib
当前目录
os.getcwd()Path.cwd()
Home 目录
os.path.expanduser("~")Path.home()
拼接路径
os.path.join(a, b)Path(a) / b
获取文件名
os.path.basename(p)Path(p).name
获取目录
os.path.dirname(p)Path(p).parent
扩展名
os.path.splitext(p)[1]Path(p).suffix
判断存在
os.path.exists(p)Path(p).exists()
创建目录
os.makedirs(p)Path(p).mkdir(parents=True)
遍历目录
os.walk(p)Path(p).rglob("*")
读文件
open(p).read()Path(p).read_text()
写文件
open(p, "w").write(s)Path(p).write_text(s)
删除文件
os.remove(p)Path(p).unlink()

💡 选型建议:
• 新项目 → 用 pathlib(更 Pythonic)
• 维护旧代码 → 继续用 os(保持一致性)
• 需要 os.walk 递归遍历 → os 更方便
• 简单路径操作 → pathlib 更简洁
• 两者可以混用:Path(os.getcwd())


12. 今日小结

os 模块核心

  • ✅ os.getcwd() 当前目录,os.listdir() 列出文件
  • ✅ os.mkdir/makedirs 创建目录,os.rmdir/removedirs 删除
  • ✅ os.rename/remove 重命名/删除文件
  • ✅ os.path.join 拼接路径,os.path.exists 判断存在
  • ✅ os.walk 递归遍历,os.scandir 快速扫描
  • ✅ os.environ.get("KEY", "default") 读取环境变量

pathlib 核心

  • ✅ Path(p) / "子路径" 用 / 拼接路径
  • ✅ .name/.stem/.suffix/.parent 路径属性
  • ✅ .exists()/.is_file()/.is_dir() 判断
  • ✅ .glob()/.rglob() 模式匹配
  • ✅ .read_text()/.write_text() 直接读写
  • ✅ .mkdir(parents=True, exist_ok=True) 创建目录

🎯 练习建议:
1. 写一个函数,递归统计某个目录下各类型文件的数量和大小
2. 写一个"文件查找器":按扩展名、大小范围、修改时间筛选文件
3. 写一个"目录同步器":比较两个目录的差异,找出新增/删除/修改的文件


📚 Day31 完成!明天进入综合练习 — 批量文件重命名工具 + 日志分析器

轻松时刻:

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 00:54:30 HTTP/2.0 GET : https://f.mffb.com.cn/a/498683.html
  2. 运行时间 : 0.184330s [ 吞吐率:5.43req/s ] 内存消耗:4,518.09kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=19a9fbf9de6989370ad126adce53538f
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000484s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000738s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.018751s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.006230s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000741s ]
  6. SELECT * FROM `set` [ RunTime:0.000209s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000554s ]
  8. SELECT * FROM `article` WHERE `id` = 498683 LIMIT 1 [ RunTime:0.006261s ]
  9. UPDATE `article` SET `lasttime` = 1783011270 WHERE `id` = 498683 [ RunTime:0.025252s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.001357s ]
  11. SELECT * FROM `article` WHERE `id` < 498683 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000648s ]
  12. SELECT * FROM `article` WHERE `id` > 498683 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.007328s ]
  13. SELECT * FROM `article` WHERE `id` < 498683 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.022717s ]
  14. SELECT * FROM `article` WHERE `id` < 498683 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.013059s ]
  15. SELECT * FROM `article` WHERE `id` < 498683 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.011101s ]
0.185970s