当前位置:首页>python>Python办公之 os 库的常见用法

Python办公之 os 库的常见用法

  • 2026-07-02 08:25:25
Python办公之 os 库的常见用法

Python办公之 os 库的常见用法

导语:在 Python 办公自动化中,os 模块是最基础也最强大的标准库之一。无论是文件管理、目录操作、路径处理还是系统交互,os 模块都能提供简洁高效的解决方案。本文将系统梳理 os 库在办公场景中的常见用法,帮助你提升日常工作效率。


一、os 模块简介

os(Operating System)模块是 Python 的标准库,提供了与操作系统交互的接口。它允许你:

  • • 操作文件和目录(创建、删除、重命名、移动)
  • • 获取文件和目录信息(大小、修改时间、权限)
  • • 遍历目录树
  • • 执行系统命令
  • • 管理环境变量
  • • 处理路径(虽然 os.path 更推荐用 pathlib 替代,但 os.path 依然广泛使用)
import os

二、路径操作 —— os.path 的核心用法

2.1 获取当前工作目录

import os

# 获取当前工作目录
cwd = os.getcwd()
print(f"当前工作目录: {cwd}")
# 输出示例: C:\Users\username\Documents\project

办公场景:批量处理文件时,先确认当前目录位置,避免路径错误导致文件找不到。

2.2 拼接路径

import os

# 安全的跨平台路径拼接
file_path = os.path.join("data""reports""2024""report.xlsx")
print(file_path)
# Windows 输出: data\reports\2024\report.xlsx
# Linux/Mac 输出: data/reports/2024/report.xlsx

为什么用 os.path.join 而不是字符串拼接?

  • • 自动处理不同操作系统的路径分隔符(Windows 用 \,Linux/Mac 用 /
  • • 避免手动处理多余的斜杠

2.3 拆分路径

import os

path = "D:\\reports\\2024\\summary.xlsx"

# 获取目录部分
directory = os.path.dirname(path)
print(f"目录: {directory}")  # D:\reports\2024

# 获取文件名
filename = os.path.basename(path)
print(f"文件名: {filename}")  # summary.xlsx

# 同时获取目录和文件名
dir_name, file_name = os.path.split(path)
print(f"目录: {dir_name}, 文件名: {file_name}")

# 分离文件名和扩展名
name, ext = os.path.splitext("summary.xlsx")
print(f"文件名: {name}, 扩展名: {ext}")  # summary, .xlsx

办公场景:批量重命名文件时,需要保留扩展名只修改文件名部分。

2.4 获取绝对路径

import os

# 相对路径转绝对路径
relative = "./data/report.xlsx"
absolute = os.path.abspath(relative)
print(f"绝对路径: {absolute}")

# 判断是否为绝对路径
print(os.path.isabs("data/file.txt"))   # False
print(os.path.isabs("D:/data/file.txt")) # True

三、文件和目录操作

3.1 判断文件或目录是否存在

import os

# 判断路径是否存在
print(os.path.exists("data/report.xlsx"))   # True 或 False
print(os.path.exists("D:/reports/"))        # True 或 False

# 判断是否为文件
print(os.path.isfile("data/report.xlsx"))   # True
print(os.path.isfile("D:/reports/"))        # False

# 判断是否为目录
print(os.path.isdir("D:/reports/"))         # True
print(os.path.isdir("data/report.xlsx"))    # False

办公场景:在读写文件前先检查文件是否存在,避免 FileNotFoundError 报错。

3.2 创建目录

import os

# 创建单层目录(父目录必须已存在)
os.mkdir("new_folder")

# 创建多层嵌套目录(推荐,父目录不存在时自动创建)
os.makedirs("reports/2024/Q1", exist_ok=True)

exist_ok=True 的作用:目录已存在时不报错,适合幂等操作。

办公场景:按年月自动创建归档目录结构。

import os
from datetime import datetime

# 自动创建当月归档目录
today = datetime.now()
archive_path = f"archive/{today.year}/{today.month:02d}"
os.makedirs(archive_path, exist_ok=True)
print(f"归档目录已创建: {archive_path}")

3.3 删除文件和目录

import os

# 删除文件
os.remove("temp_report.xlsx")

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

# 删除非空目录树(需要 shutil 配合)
import shutil
shutil.rmtree("old_reports")

安全提醒:删除操作不可恢复,建议删除前先备份或移到回收站。

3.4 重命名和移动文件

import os

# 重命名文件
os.rename("old_name.xlsx""new_name.xlsx")

# 移动文件(本质是重命名路径)
os.rename("data/report.xlsx""archive/2024/report.xlsx")

办公场景:批量给文件添加日期前缀。

import os
from datetime import datetime

today = datetime.now().strftime("%Y%m%d")

for filename in os.listdir("reports"):
if filename.endswith(".xlsx"):
        old_path = os.path.join("reports", filename)
        new_path = os.path.join("reports"f"{today}_{filename}")
        os.rename(old_path, new_path)
print(f"已重命名: {filename} -> {today}_{filename}")

四、文件信息获取

4.1 获取文件大小

import os

file_path = "data/report.xlsx"
size_bytes = os.path.getsize(file_path)
print(f"文件大小: {size_bytes} 字节")

# 转换为人类可读的格式
defformat_size(size_bytes):
for unit in ['B''KB''MB''GB']:
if size_bytes < 1024:
returnf"{size_bytes:.2f}{unit}"
        size_bytes /= 1024
returnf"{size_bytes:.2f} TB"

print(f"文件大小: {format_size(os.path.getsize(file_path))}")

4.2 获取文件修改时间

import os
from datetime import datetime

file_path = "data/report.xlsx"

# 获取最后修改时间(返回时间戳)
mtime = os.path.getmtime(file_path)
print(f"最后修改时间: {datetime.fromtimestamp(mtime)}")

# 获取创建时间(Windows 有效)
ctime = os.path.getctime(file_path)
print(f"创建时间: {datetime.fromtimestamp(ctime)}")

# 获取最后访问时间
atime = os.path.getatime(file_path)
print(f"最后访问时间: {datetime.fromtimestamp(atime)}")

办公场景:找出超过 30 天未修改的文件进行清理。

import os
from datetime import datetime, timedelta

cutoff = datetime.now() - timedelta(days=30)

for filename in os.listdir("temp_files"):
    file_path = os.path.join("temp_files", filename)
if os.path.isfile(file_path):
        mtime = datetime.fromtimestamp(os.path.getmtime(file_path))
if mtime < cutoff:
print(f"可清理: {filename} (最后修改: {mtime})")
# os.remove(file_path)  # 取消注释后实际删除

五、目录遍历 —— os.listdir 与 os.walk

5.1 列出目录内容 —— os.listdir

import os

# 列出当前目录下所有文件和子目录
items = os.listdir(".")
print(items)
# 输出: ['data', 'report.xlsx', 'summary.pdf', 'scripts']

# 列出指定目录
items = os.listdir("D:/reports")
for item in items:
print(item)

办公场景:统计某目录下 Excel 文件的数量。

import os

count = 0
for item in os.listdir("reports"):
if item.endswith(('.xlsx''.xls')):
        count += 1
print(f"共有 {count} 个 Excel 文件")

5.2 递归遍历目录树 —— os.walk(核心高频用法)

os.walk() 是办公自动化中最常用的函数之一,它能递归遍历目录树。

import os

# 基本用法
for dirpath, dirnames, filenames in os.walk("D:/project"):
print(f"当前目录: {dirpath}")
print(f"子目录: {dirnames}")
print(f"文件: {filenames}")
print("---")

返回值说明

  • • dirpath:当前遍历到的目录路径(字符串)
  • • dirnames:当前目录下的子目录列表(字符串列表)
  • • filenames:当前目录下的文件列表(字符串列表)

5.3 实战:搜集所有 Excel 文件

import os

deffind_excel_files(root_dir):
"""递归查找目录下所有 Excel 文件"""
    excel_files = []
for dirpath, dirnames, filenames in os.walk(root_dir):
for filename in filenames:
if filename.endswith(('.xlsx''.xls')):
                full_path = os.path.join(dirpath, filename)
                excel_files.append(full_path)
return excel_files

# 使用示例
files = find_excel_files("D:/work/reports")
print(f"共找到 {len(files)} 个 Excel 文件:")
for f in files:
print(f"  {f}")

5.4 实战:统计各类型文件数量和总大小

import os

defanalyze_directory(root_dir):
"""分析目录下各类型文件的数量和大小"""
    stats = {}  # {扩展名: {'count': 数量, 'size': 总大小}}

for dirpath, dirnames, filenames in os.walk(root_dir):
# 跳过隐藏目录
        dirnames[:] = [d for d in dirnames ifnot d.startswith('.')]

for filename in filenames:
if filename.startswith('.'):
continue

            ext = os.path.splitext(filename)[1].lower() or'无扩展名'
            file_path = os.path.join(dirpath, filename)

try:
                size = os.path.getsize(file_path)
except OSError:
                size = 0

if ext notin stats:
                stats[ext] = {'count'0'size'0}
            stats[ext]['count'] += 1
            stats[ext]['size'] += size

return stats

# 使用示例
stats = analyze_directory("D:/work")
for ext, info insorted(stats.items()):
print(f"{ext}{info['count']} 个文件, 总计 {info['size'] / 1024 / 1024:.2f} MB")

5.5 实战:批量给文件名添加序号

import os

defbatch_rename_with_counter(directory, prefix="文档"):
"""批量给目录下文件添加序号前缀"""
    files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))]

for idx, filename inenumerate(files, start=1):
        old_path = os.path.join(directory, filename)
        name, ext = os.path.splitext(filename)
        new_name = f"{prefix}_{idx:03d}{ext}"
        new_path = os.path.join(directory, new_name)
        os.rename(old_path, new_path)
print(f"已重命名: {filename} -> {new_name}")

# 使用示例
# batch_rename_with_counter("D:/work/documents", "报告")

六、环境变量操作

6.1 读取环境变量

import os

# 读取环境变量
username = os.environ.get("USERNAME")  # Windows
print(f"当前用户: {username}")

# 读取 PATH 环境变量
path = os.environ.get("PATH")
print(f"PATH: {path}")

# 安全读取(带默认值)
api_key = os.environ.get("API_KEY""default_key")

6.2 设置环境变量

import os

# 设置环境变量(仅在当前 Python 进程及其子进程中有效)
os.environ["MY_APP_ENV"] = "production"
os.environ["OUTPUT_DIR"] = "D:/output"

print(os.environ.get("MY_APP_ENV"))  # production

办公场景:在自动化脚本中使用环境变量管理配置(如数据库连接、输出路径),避免硬编码。


七、系统命令执行

7.1 os.system(简单但不推荐)

import os

# 执行系统命令(返回值是命令的退出码)
exit_code = os.system("dir")        # Windows 列出目录
exit_code = os.system("ls -la")     # Linux/Mac

缺点:无法获取命令输出内容,安全性较差。

7.2 os.popen(获取命令输出)

import os

# 执行命令并获取输出
result = os.popen("dir").read()
print(result)

7.3 推荐使用 subprocess(替代方案)

虽然不属于 os 模块,但现代 Python 更推荐使用 subprocess

import subprocess

# 执行命令并获取输出
result = subprocess.run(["dir"], shell=True, capture_output=True, text=True)
print(result.stdout)

八、权限和属性操作

8.1 修改文件权限

import os
import stat

file_path = "report.xlsx"

# 设置为只读(Windows 效果有限,Linux 上更常用)
os.chmod(file_path, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

# 设置为可读写
os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR)

8.2 检查文件权限

import os
import stat

file_path = "report.xlsx"
mode = os.stat(file_path).st_mode

# 检查是否可读
is_readable = bool(mode & stat.S_IRUSR)
print(f"可读: {is_readable}")

九、临时文件和特殊目录

9.1 获取系统临时目录

import os

temp_dir = os.path.normpath(os.environ.get("TEMP"or os.environ.get("TMP"))
print(f"临时目录: {temp_dir}")

# 或者使用 tempfile 模块(更推荐)
import tempfile
print(f"临时目录: {tempfile.gettempdir()}")

9.2 获取用户主目录

import os

home = os.path.expanduser("~")
print(f"用户主目录: {home}")

# 拼接用户特定路径
config_path = os.path.join(home, ".config""myapp")
print(f"配置目录: {config_path}")

十、综合实战项目

10.1 项目一:自动整理下载文件夹

import os
import shutil
from datetime import datetime

deforganize_downloads(download_dir):
"""按文件类型自动整理下载文件夹"""

# 定义分类规则
    categories = {
"Images": [".jpg"".jpeg"".png"".gif"".bmp"".svg"".webp"],
"Documents": [".pdf"".doc"".docx"".txt"".xls"".xlsx"".ppt"".pptx"],
"Archives": [".zip"".rar"".7z"".tar"".gz"],
"Videos": [".mp4"".avi"".mkv"".mov"".wmv"".flv"],
"Audio": [".mp3"".wav"".flac"".aac"".ogg"],
"Programs": [".exe"".msi"".dmg"".apk"],
    }

# 创建分类目录
for category in categories:
        os.makedirs(os.path.join(download_dir, category), exist_ok=True)

# 遍历并移动文件
for filename in os.listdir(download_dir):
        file_path = os.path.join(download_dir, filename)

# 跳过目录和已分类的文件夹
if os.path.isdir(file_path) or filename.startswith("."):
continue

        ext = os.path.splitext(filename)[1].lower()

# 找到对应分类
        target_category = None
for category, extensions in categories.items():
if ext in extensions:
                target_category = category
break

if target_category:
            dest_path = os.path.join(download_dir, target_category, filename)
# 处理同名文件
if os.path.exists(dest_path):
                name, ext = os.path.splitext(filename)
                timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
                dest_path = os.path.join(download_dir, target_category, f"{name}_{timestamp}{ext}")

            shutil.move(file_path, dest_path)
print(f"已移动: {filename} -> {target_category}/")

# 使用示例
# organize_downloads("C:/Users/username/Downloads")

10.2 项目二:查找重复文件

import os
import hashlib

deffind_duplicate_files(root_dir):
"""查找目录下的重复文件(基于 MD5)"""

deffile_md5(file_path):
"""计算文件 MD5 值"""
        hasher = hashlib.md5()
withopen(file_path, 'rb'as f:
while chunk := f.read(8192):
                hasher.update(chunk)
return hasher.hexdigest()

# 按文件大小初步分组
    size_groups = {}
for dirpath, dirnames, filenames in os.walk(root_dir):
for filename in filenames:
            file_path = os.path.join(dirpath, filename)
try:
                size = os.path.getsize(file_path)
if size notin size_groups:
                    size_groups[size] = []
                size_groups[size].append(file_path)
except OSError:
continue

# 对大小相同的文件计算 MD5
    duplicates = {}
for size, paths in size_groups.items():
iflen(paths) < 2:
continue

        md5_groups = {}
for path in paths:
            md5 = file_md5(path)
if md5 notin md5_groups:
                md5_groups[md5] = []
            md5_groups[md5].append(path)

for md5, paths in md5_groups.items():
iflen(paths) > 1:
                duplicates[md5] = paths

return duplicates

# 使用示例
duplicates = find_duplicate_files("D:/work")
for md5, paths in duplicates.items():
print(f"\n重复文件 (MD5: {md5}):")
for p in paths:
        size = os.path.getsize(p) / 1024
print(f"  {p} ({size:.1f} KB)")

10.3 项目三:生成文件目录索引

import os

defgenerate_file_index(root_dir, output_file="file_index.md"):
"""生成目录下所有文件的 Markdown 索引"""

defget_tree(dirpath, prefix=""):
        lines = []
        items = sorted(os.listdir(dirpath))
# 过滤隐藏文件
        items = [i for i in items ifnot i.startswith('.')]

for idx, item inenumerate(items):
            item_path = os.path.join(dirpath, item)
            is_last = (idx == len(items) - 1)
            connector = "└── "if is_last else"├── "

            lines.append(f"{prefix}{connector}{item}")

if os.path.isdir(item_path):
                extension = "    "if is_last else"│   "
                lines.extend(get_tree(item_path, prefix + extension))

return lines

withopen(output_file, 'w', encoding='utf-8'as f:
        f.write(f"# 📁 {os.path.basename(root_dir)} 目录索引\n\n")
        f.write(f"**生成时间**: {__import__('datetime').datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n")
        f.write("```text\n")
        f.write(f"{os.path.basename(root_dir)}\n")
        tree_lines = get_tree(root_dir)
        f.write('\n'.join(tree_lines))
        f.write("\n```\n")

print(f"索引已生成: {output_file}")

# 使用示例
# generate_file_index("D:/project", "project_index.md")

10.4 项目四:批量检测空目录

import os

deffind_empty_directories(root_dir):
"""查找所有空目录(不含任何文件和子目录)"""
    empty_dirs = []

for dirpath, dirnames, filenames in os.walk(root_dir, topdown=False):
# topdown=False 从最深层目录开始遍历
ifnot dirnames andnot filenames:
            empty_dirs.append(dirpath)

return empty_dirs

# 使用示例
empty = find_empty_directories("D:/project")
if empty:
print(f"找到 {len(empty)} 个空目录:")
for d in empty:
print(f"  {d}")
else:
print("没有找到空目录")

十一、os 模块与 pathlib 的对比

虽然 os 模块功能强大,Python 3.4+ 引入了更现代的 pathlib 模块。两者的对比:

操作
os
 / os.path
pathlib
获取当前目录
os.getcwd()Path.cwd()
路径拼接
os.path.join("a", "b")Path("a") / "b"
判断存在
os.path.exists(path)Path(path).exists()
判断文件
os.path.isfile(path)Path(path).is_file()
获取文件名
os.path.basename(path)Path(path).name
获取扩展名
os.path.splitext(path)[1]Path(path).suffix
获取父目录
os.path.dirname(path)Path(path).parent
列出目录
os.listdir(path)Path(path).iterdir()

建议:新项目优先使用 pathlib,但 os 模块在以下场景仍不可替代:

  • • 环境变量操作(os.environ
  • • 系统命令执行(os.systemos.popen
  • • 进程管理(os.forkos.exec*
  • • 文件权限(os.chmod
  • • os.walk() 遍历目录树

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

12.1 路径中的反斜杠问题

# ❌ 错误写法(\t 会被解释为制表符)
path = "C:\temp\report.xlsx"

# ✅ 正确写法一:原始字符串
path = r"C:\temp\report.xlsx"

# ✅ 正确写法二:双反斜杠
path = "C:\\temp\\report.xlsx"

# ✅ 正确写法三:正斜杠(Windows 也支持)
path = "C:/temp/report.xlsx"

# ✅ 正确写法四:os.path.join(推荐)
path = os.path.join("C:""temp""report.xlsx")

12.2 相对路径的不确定性

# ❌ 问题:相对路径依赖当前工作目录,不同运行方式结果不同
os.listdir("data")

# ✅ 解决:使用脚本所在目录作为基准
script_dir = os.path.dirname(os.path.abspath(__file__))
data_dir = os.path.join(script_dir, "data")
os.listdir(data_dir)

12.3 遍历时的隐藏文件

# os.walk 会遍历隐藏目录,os.listdir 会列出隐藏文件
# 如果需要过滤,需要手动处理

for dirpath, dirnames, filenames in os.walk(root):
# 跳过隐藏目录(原地修改 dirnames 列表)
    dirnames[:] = [d for d in dirnames ifnot d.startswith('.')]

for filename in filenames:
ifnot filename.startswith('.'):
# 处理文件
pass

12.4 权限不足

# 某些系统目录或正在使用的文件可能无法读取/删除
try:
    os.remove("important_file.xlsx")
except PermissionError:
print("权限不足,文件可能正在被其他程序使用")
except FileNotFoundError:
print("文件不存在")

十三、速查表

功能
函数
示例
当前工作目录
os.getcwd()
返回当前路径
切换工作目录
os.chdir(path)
切换目标目录
列出目录
os.listdir(path)
返回文件/子目录列表
创建目录
os.makedirs(path)
递归创建目录
删除文件
os.remove(path)
删除指定文件
删除空目录
os.rmdir(path)
只能删除空目录
重命名/移动
os.rename(src, dst)
重命名或移动
判断存在
os.path.exists(path)
返回 True/False
判断文件
os.path.isfile(path)
返回 True/False
判断目录
os.path.isdir(path)
返回 True/False
获取文件大小
os.path.getsize(path)
返回字节数
获取修改时间
os.path.getmtime(path)
返回时间戳
路径拼接
os.path.join(a, b)
自动处理分隔符
分离扩展名
os.path.splitext(path)
返回 (路径, 扩展名)
递归遍历
os.walk(top)
返回 (目录, 子目录, 文件)
执行命令
os.system(cmd)
执行系统命令
读取环境变量
os.environ.get(key)
获取环境变量值
设置环境变量
os.environ[key] = value
设置环境变量
获取绝对路径
os.path.abspath(path)
返回绝对路径
用户主目录
os.path.expanduser("~")
返回 ~ 的实际路径

十四、总结

os 模块是 Python 办公自动化不可或缺的基础工具。本文覆盖了从路径处理、文件操作、目录遍历到环境变量、系统命令等核心功能,并结合实际办公场景给出了多个可复用的代码示例。

关键要点回顾

  1. 1. 路径操作:始终使用 os.path.join 拼接路径,避免手写分隔符
  2. 2. 目录遍历os.walk 是批量处理文件的核心武器
  3. 3. 安全检查:文件读写前先判断存在性,操作时捕获异常
  4. 4. 环境变量:用 os.environ 管理配置,避免硬编码
  5. 5. 与 pathlib 互补os 和 pathlib 各有优势,合理搭配使用

希望本文能帮助你在日常办公中更高效地使用 Python 的 os 模块,提升文件管理的自动化水平。


延伸阅读

  • • Python 官方文档 - os 模块
  • • Python 官方文档 - os.path 模块
  • • Python 官方文档 - pathlib 模块
  • • Python 官方文档 - shutil 模块

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-02 23:26:15 HTTP/2.0 GET : https://f.mffb.com.cn/a/496334.html
  2. 运行时间 : 0.111948s [ 吞吐率:8.93req/s ] 内存消耗:4,769.55kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=0806551ce6f1b2f2f91ed6bbc408429b
  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.000891s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001579s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000675s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000462s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000839s ]
  6. SELECT * FROM `set` [ RunTime:0.000194s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000492s ]
  8. SELECT * FROM `article` WHERE `id` = 496334 LIMIT 1 [ RunTime:0.004507s ]
  9. UPDATE `article` SET `lasttime` = 1783005976 WHERE `id` = 496334 [ RunTime:0.001816s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000260s ]
  11. SELECT * FROM `article` WHERE `id` < 496334 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000437s ]
  12. SELECT * FROM `article` WHERE `id` > 496334 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000428s ]
  13. SELECT * FROM `article` WHERE `id` < 496334 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.008371s ]
  14. SELECT * FROM `article` WHERE `id` < 496334 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.006415s ]
  15. SELECT * FROM `article` WHERE `id` < 496334 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.016326s ]
0.113570s