当前位置:首页>python>Python pathlib模块:告别os.path的笨拙,拥抱现代路径操作!

Python pathlib模块:告别os.path的笨拙,拥抱现代路径操作!

  • 2026-03-28 15:47:09
Python pathlib模块:告别os.path的笨拙,拥抱现代路径操作!
引言:为什么你的路径代码总是出问题?
在日常Python开发中,你是否经常遭遇以下困境:
  • 跨平台兼容性噩梦:在Windows上写好的代码,到Linux上就报错,因为硬编码了反斜杠\或正斜杠/
  • 冗长的函数调用链:为了获取一个文件的父目录,需要写os.path.dirname(os.path.dirname(file_path)),可读性差
  • 容易出错的手动拼接os.path.join()遇到绝对路径会丢弃前面的所有部分,导致路径丢失
  • 对象与字符串的转换混乱:在os.path函数和文件操作之间不断进行str()Path转换
如果你也有这些烦恼,那么pathlib模块就是你的救星!作为Python官方推荐的现代化路径操作库,pathlib采用面向对象的设计理念,将文件路径从"字符串"升级为"智能对象",让路径操作变得直观、安全、优雅。
今天,我们将深度剖析pathlib模块的核心设计、实用API和最佳实践,通过丰富的代码示例和实战场景,让你彻底掌握这个"Python现代化编程的必备武器"!
一、pathlib模块概述
1.1 设计哲学:从字符串到对象
pathlib模块在Python 3.4中首次引入,其核心思想是:将文件系统路径视为一等对象,而非普通的字符串。这种设计带来了革命性的改变:
  1. 面向对象API:路径不再是字符串,而是拥有丰富方法的Path对象
  2. 运算符重载:使用/运算符进行路径拼接,语法自然直观
  3. 跨平台透明:内部自动处理不同操作系统的路径分隔符差异
  4. 链式调用:支持Path("data").mkdir(exist_ok=True).joinpath("file.txt")的流畅写法
1.2 核心类层次结构
pathlib模块包含两大类路径对象:
类别
核心类
功能特点
使用场景
纯路径
PurePath
只提供路径计算操作,不访问实际文件系统
跨平台路径分析、URL处理
PurePosixPath
Unix风格纯路径
Linux/macOS路径逻辑处理
PureWindowsPath
Windows风格纯路径
Windows路径逻辑处理
具体路径
Path
继承PurePath,增加文件系统操作
实际文件读写、目录管理
PosixPath
Unix风格具体路径
Linux/macOS实际文件操作
WindowsPath
Windows风格具体路径
Windows实际文件操作
关键选择原则
  • 99%的情况下,直接使用Path类(它会根据操作系统自动选择PosixPathWindowsPath
  • 仅在需要跨平台路径分析且不涉及实际文件系统时使用PurePath
1.3 与os.path的历史对比
Python路径操作经历了三个阶段:
  1. 远古时代(Python 2.x)os.path函数集合,字符串操作为主
  2. 过渡时期(Python 3.0-3.3)os.path仍是主流,但开始有面向对象需求
  3. 现代时代(Python 3.4+)pathlib成为官方推荐,全面替代os.path
官方态度明确:自Python 3.6起,标准库文档中的路径操作示例已全面使用pathlib。新项目应优先选择pathlib,旧项目建议逐步迁移。
二、Path核心类详解
2.1 创建Path对象
创建Path对象有多种方式,适应不同场景:
from pathlib import Path# 方式1:从字符串直接创建p1 = Path("data/config.ini")  # 相对路径p2 = Path("/home/user/docs")  # 绝对路径(Unix)p3 = Path(r"C:\Windows\System32")  # 绝对路径(Windows)# 方式2:拼接创建(推荐!)config_path = Path("data") / "config" / "settings.ini"print(f"拼接路径: {config_path}")# 输出: data/config/settings.ini# 方式3:获取当前工作目录和脚本所在目录current_dir = Path.cwd()  # 当前工作目录script_dir = Path(__file__).parent.resolve()  # 脚本所在目录(重要!)print(f"脚本目录: {script_dir}")
2.2 路径属性访问
Path对象提供了直观的属性访问,替代繁琐的os.path函数调用:
# 创建一个示例路径p = Path("/home/user/docs/report.pdf")# 基础属性print(f"原始路径: {p}")              # /home/user/docs/report.pdfprint(f"父目录: {p.parent}")         # /home/user/docsprint(f"文件名(含后缀): {p.name}")   # report.pdfprint(f"文件名(无后缀): {p.stem}")   # reportprint(f"后缀名: {p.suffix}")         # .pdfprint(f"根目录: {p.root}")           # /# 多重后缀处理archive = Path("archive.tar.gz")print(f"后缀列表: {archive.suffixes}")  # ['.tar', '.gz']print(f"最后后缀: {archive.suffix}")    # .gz# 绝对路径与规范化relative = Path("data/../config/./settings.ini")abs_path = relative.resolve()  # 解析为绝对路径,并规范化print(f"规范化路径: {abs_path}")# 输出: /current/working/dir/config/settings.ini
2.3 文件系统检测方法
pathlib提供了比os.path更优雅的存在性和类型检测:
# 创建测试路径test_file = Path("test.txt")test_dir = Path("test_dir")# 存在性检测print(f"文件存在: {test_file.exists()}")  # 检查文件或目录是否存在print(f"是否为文件: {test_file.is_file()}")  # 精确判断是否为文件print(f"是否为目录: {test_file.is_dir()}")   # 精确判断是否为目录# 高级检测print(f"是否为绝对路径: {test_file.is_absolute()}")print(f"是否为符号链接: {test_file.is_symlink()}")print(f"是否为挂载点: {test_file.is_mount()}")  # 检查是否为挂载点# 跨平台安全检测if test_file.exists() and test_file.is_file():# 安全操作文件    print("文件存在且是普通文件")
2.4 文件与目录操作
pathlib最大的亮点之一是内置了丰富的文件系统操作方法:
# 目录操作data_dir = Path("data")# 安全创建目录(自动处理父目录)data_dir.mkdir(exist_ok=True)  # 目录已存在时不报错data_dir.mkdir(parents=True, exist_ok=True)  # 同时创建父目录# 删除目录(需为空)data_dir.rmdir()# 遍历目录for item in data_dir.iterdir():if item.is_file():        print(f"文件: {item.name}")elif item.is_dir():        print(f"目录: {item.name}")# 文件操作config_file = data_dir / "config.json"# 写入文件(自动创建、自动关闭)config_file.write_text('{"key": "value"}', encoding="utf-8")# 读取文件(无需手动open)content = config_file.read_text(encoding="utf-8")print(f"文件内容: {content}")# 重命名/移动new_file = config_file.with_name("settings.json")config_file.rename(new_file)# 修改后缀txt_file = Path("document.txt")md_file = txt_file.with_suffix(".md")print(f"新文件: {md_file}")  # document.md
三、高级功能与新特性
3.1 Python 3.12+ 新功能
从Python 3.12开始,pathlib增加了一系列强大功能:
# 1. walk()方法:替代os.walk()for root, dirs, files in Path("project").walk():    print(f"目录: {root}")    print(f"子目录数: {len(dirs)}")    print(f"文件数: {len(files)}")# 2. case_sensitive参数:跨平台大小写处理# Windows上默认case_sensitive=False,Unix上为Truetxt_files = list(Path(".").glob("*.TXT", case_sensitive=False))# 3. 子类化支持:自定义Path类classProjectPath(Path):"""自定义项目路径类"""def__init__(self, *args):        super().__init__(*args)    @propertydefis_source_file(self):return self.suffix in ['.py''.js''.ts']# 使用自定义类src_file = ProjectPath("src/main.py")print(f"是否为源码文件: {src_file.is_source_file}")
3.2 路径关系判断
Python 3.9+ 引入了方便的路径关系判断方法:
# 创建路径对象project_root = Path("/home/user/project")source_file = project_root / "src" / "main.py"external_file = Path("/var/log/system.log")# 判断路径相对关系print(f"source_file相对于project_root: {source_file.is_relative_to(project_root)}")  # Trueprint(f"external_file相对于project_root: {external_file.is_relative_to(project_root)}")  # False# 安全路径操作:确保文件在项目目录内defsafe_read_file(root: Path, file_path: str) -> str:"""安全读取文件,防止目录遍历攻击"""    full_path = (root / file_path).resolve()ifnot full_path.is_relative_to(root.resolve()):raise ValueError(f"非法路径: {file_path}")return full_path.read_text()# 使用示例try:    content = safe_read_file(project_root, "config/settings.ini")    print("文件读取成功")except ValueError as e:    print(f"安全错误: {e}")
3.3 通配符与模式匹配
pathlib的glob功能比os.path.glob更强大:
# 基础globpy_files = list(Path("src").glob("*.py"))print(f"Python文件数: {len(py_files)}")# 递归glob(rglob)all_py_files = list(Path(".").rglob("*.py"))print(f"所有Python文件: {len(all_py_files)}")# 复杂模式匹配log_files = list(Path("logs").glob("app-*.log"))data_files = list(Path("data").glob("202[4-5]-*.csv"))# 使用match方法进行模式测试patterns = ["*.py""test_*.py""*.txt"]test_file = Path("test_module.py")for pattern in patterns:    matches = test_file.match(pattern)print(f"'{test_file}' 匹配 '{pattern}': {matches}")
四、实战应用场景
4.1 场景一:项目配置文件管理
问题:管理多环境配置文件,如开发、测试、生产环境
传统方案:硬编码路径,手动拼接,容易出错
pathlib方案:动态构建,安全可靠
from pathlib import Pathimport jsonclassConfigManager:"""项目配置管理器"""def__init__(self, project_root=None):        self.project_root = Path(project_root or Path.cwd())        self.config_dir = self.project_root / "config"defget_config_path(self, env="development"):"""获取指定环境的配置文件路径"""        config_file = self.config_dir / f"{env}.json"# 安全检查:确保文件在项目目录内        config_file = config_file.resolve()ifnot config_file.is_relative_to(self.project_root.resolve()):raise ValueError("配置文件路径越界")return config_filedefload_config(self, env="development"):"""加载指定环境的配置"""        config_path = self.get_config_path(env)ifnot config_path.exists():# 创建默认配置            default_config = {"database": {"host""localhost","port"5432,"name"f"app_{env}"                },"logging": {"level""INFO"if env == "production"else"DEBUG","file"f"logs/app_{env}.log"                }            }            config_path.parent.mkdir(exist_ok=True)            config_path.write_text(                json.dumps(default_config, indent=2),                encoding="utf-8"            )return default_config# 读取现有配置        content = config_path.read_text(encoding="utf-8")return json.loads(content)# 使用示例config_manager = ConfigManager()dev_config = config_manager.load_config("development")prod_config = config_manager.load_config("production")
4.2 场景二:日志文件轮转与归档
问题:自动管理日志文件,按日期归档,防止磁盘占满
传统方案:复杂脚本,跨平台兼容性差
pathlib方案:优雅简洁,跨平台透明
from pathlib import Pathfrom datetime import datetime, timedeltaimport shutilclassLogRotator:"""日志轮转管理器"""def__init__(self, log_dir="logs", retention_days=30):        self.log_dir = Path(log_dir)        self.retention_days = retention_days        self.archive_dir = self.log_dir / "archive"defrotate_logs(self):"""执行日志轮转"""# 确保目录存在        self.log_dir.mkdir(exist_ok=True)        self.archive_dir.mkdir(exist_ok=True)# 获取当前时间        now = datetime.now()# 遍历日志文件for log_file in self.log_dir.glob("app_*.log"):ifnot log_file.is_file():continue# 获取文件修改时间            mtime = datetime.fromtimestamp(log_file.stat().st_mtime)            days_old = (now - mtime).days# 超过1天的日志进行归档if days_old >= 1:# 构建归档文件名                date_str = mtime.strftime("%Y%m%d")                new_name = f"{log_file.stem}_{date_str}{log_file.suffix}"                archive_path = self.archive_dir / new_name# 移动文件                log_file.rename(archive_path)                print(f"归档: {log_file.name} → {new_name}")# 清理过期归档        self.cleanup_old_archives()defcleanup_old_archives(self):"""清理超过保留期限的归档文件"""        cutoff_date = datetime.now() - timedelta(days=self.retention_days)for archive_file in self.archive_dir.glob("*.log"):            mtime = datetime.fromtimestamp(archive_file.stat().st_mtime)if mtime < cutoff_date:                archive_file.unlink()                print(f"删除过期归档: {archive_file.name}")# 使用示例rotator = LogRotator(retention_days=7)rotator.rotate_logs()
4.3 场景三:批量文件处理与转换
问题:批量处理项目中的文件,如转换图片格式、重命名文档
传统方案:复杂循环,错误处理困难
pathlib方案:链式操作,异常安全
from pathlib import Pathfrom PIL import Imageimport osclassBatchFileProcessor:"""批量文件处理器"""def__init__(self, source_dir, target_dir):        self.source_dir = Path(source_dir)        self.target_dir = Path(target_dir)        self.target_dir.mkdir(parents=True, exist_ok=True)defconvert_images_format(self, from_ext=".jpg", to_ext=".webp", quality=80):"""批量转换图片格式"""        converted_count = 0for img_file in self.source_dir.rglob(f"*{from_ext}"):ifnot img_file.is_file():continuetry:# 构建目标路径                relative_path = img_file.relative_to(self.source_dir)                new_stem = relative_path.stem                target_file = self.target_dir / f"{new_stem}{to_ext}"# 转换图片with Image.open(img_file) as img:                    img.save(target_file, quality=quality)                converted_count += 1                print(f"转换: {img_file.name} → {target_file.name}")except Exception as e:                print(f"转换失败 {img_file}{e}")return converted_countdefrename_files_with_prefix(self, prefix="backup_"):"""批量添加前缀重命名"""for file_path in self.source_dir.iterdir():if file_path.is_file():                new_name = f"{prefix}{file_path.name}"                new_path = file_path.with_name(new_name)                file_path.rename(new_path)                print(f"重命名: {file_path.name} → {new_name}")# 使用示例processor = BatchFileProcessor("images/original""images/converted")converted = processor.convert_images_format(".png"".webp", quality=85)print(f"成功转换 {converted} 张图片")
五、性能对比与优化建议
5.1 pathlib vs os.path 性能分析
性能测试代码
import timefrom pathlib import Pathimport osdefperformance_comparison():"""pathlib与os.path性能对比"""    test_count = 10000    test_path = __file__# 测试os.path    start = time.perf_counter()for _ in range(test_count):        dirname = os.path.dirname(test_path)        basename = os.path.basename(test_path)        exists = os.path.exists(test_path)    os_time = time.perf_counter() - start# 测试pathlib    start = time.perf_counter()    p = Path(test_path)for _ in range(test_count):        dirname = p.parent        basename = p.name        exists = p.exists()    pathlib_time = time.perf_counter() - start    print(f"os.path 耗时: {os_time:.4f}秒")    print(f"pathlib 耗时: {pathlib_time:.4f}秒")    print(f"性能差异: {(pathlib_time - os_time)/os_time*100:.2f}%")# 执行测试performance_comparison()
测试结果分析
  • os.path略快于pathlib(约5-15%差异)
  • 差异主要来自Path对象创建开销
  • 在实际业务代码中,性能差异通常可忽略不计
  • pathlib的代码可读性和安全性优势远超微小性能损失
5.2 优化建议
  1. 避免高频循环中的Path对象创建
# 不推荐:每次循环都创建新对象for filename in file_list:    p = Path(filename)  # 每次循环都创建新Path对象if p.exists():        process(p)# 推荐:预创建Path对象或缓存path_objects = [Path(f) for f in file_list]for p in path_objects:if p.exists():        process(p)
  1. 合理使用resolve()
# resolve()开销较大,避免不必要的调用p = Path("data/config.ini")# 需要时再调用if need_absolute:    abs_path = p.resolve()# 避免重复调用cached_resolved = p.resolve()
  1. 批量操作优化
# 批量读取文件:使用生成器避免内存爆炸defread_files_batch(file_paths, batch_size=100):for i in range(0, len(file_paths), batch_size):        batch = file_paths[i:i+batch_size]for file_path in batch:yield file_path.read_text()# 批量写入:使用临时文件+原子移动import tempfiledefsafe_batch_write(target_dir, file_data):with tempfile.TemporaryDirectory() as tmp_dir:        tmp_path = Path(tmp_dir)for filename, content in file_data.items():            tmp_file = tmp_path / filename            tmp_file.write_text(content)# 原子移动for tmp_file in tmp_path.iterdir():            target_file = target_dir / tmp_file.name            tmp_file.replace(target_file)
六、迁移指南:从os.path到pathlib
6.1 常见转换模式
os.path写法
pathlib等价写法
说明
os.path.join(a, b)
Path(a) / b
使用/运算符更直观
os.path.dirname(p)
p.parent
属性访问,支持链式调用
os.path.basename(p)
p.name
直接获取文件名
os.path.splitext(p)[0]
p.stem
获取无后缀的文件名
os.path.splitext(p)[1]
p.suffix
获取后缀名
os.path.exists(p)
p.exists()
方法调用,支持链式
os.path.isdir(p)
p.is_dir()
精确判断目录
os.path.isfile(p)
p.is_file()
精确判断文件
os.path.getsize(p)
p.stat().st_size
通过stat()获取元数据
6.2 迁移步骤建议
  1. 逐步替换,不要一次性重写
# 旧代码import osconfig_path = os.path.join(os.path.dirname(__file__), "config""settings.ini")if os.path.exists(config_path):with open(config_path) as f:        content = f.read()# 新代码(第一步:导入pathlib)import osfrom pathlib import Path# 逐步替换script_dir = Path(__file__).parentconfig_path = script_dir / "config" / "settings.ini"if config_path.exists():    content = config_path.read_text()
  1. 处理遗留代码中的硬编码路径
# 旧代码中的硬编码路径data_file = "C:\\Users\\name\\data\\input.csv"# 新代码:使用Path和跨平台处理from pathlib import Path# 方法1:使用用户目录home_dir = Path.home()data_file = home_dir / "data" / "input.csv"# 方法2:使用项目相对路径project_root = Path(__file__).parent.parentdata_file = project_root / "data" / "input.csv"
  1. 注意API差异
# os.path.join的特殊行为result = os.path.join("/home/user""/tmp/file.txt")# 结果: '/tmp/file.txt'(前面的路径被丢弃)# pathlib的/运算符更合理result = Path("/home/user") / "/tmp/file.txt"# 结果: '/tmp/file.txt'(同样丢弃前面)# 最佳实践:确保使用相对路径safe_result = Path("/home/user") / "tmp" / "file.txt"
6.3 常见陷阱与解决方案
  1. 混合使用os.path和Path
# 危险:混合类型导致错误p = Path("data/config.ini")if os.path.exists(p):  # 可能出错,老版本Python不支持    content = p.read_text()# 安全:统一使用Path方法if p.exists():    content = p.read_text()
  1. 相对路径的歧义
# 问题:相对路径依赖当前工作目录p = Path("../config.ini")content = p.read_text()  # 依赖于os.getcwd()# 解决:明确基准目录base_dir = Path(__file__).parentabs_path = (base_dir / p).resolve()content = abs_path.read_text()
  1. 跨平台换行符处理
# 问题:Windows和Unix换行符不同content = p.read_text()  # 默认使用系统换行符# 解决:明确指定换行符content = p.read_text(newline="\n")  # 统一使用Unix换行符
七、常见问题与解决方案
7.1 Q:如何在老项目中使用pathlib?
A:可以渐进式迁移:
  1. 在新代码中使用pathlib
  2. 逐步替换高风险路径操作(如os.path.join
  3. 使用兼容层包装旧代码
7.2 Q:pathlib与第三方库兼容性如何?
A:现代Python库(如pandas、numpy)都支持Path对象。如果遇到不支持的情况,使用str(p)转换:
import pandas as pdp = Path("data/data.csv")df = pd.read_csv(str(p))  # 转换为字符串
7.3 Q:如何处理网络路径和特殊设备?
A:pathlib主要处理本地文件系统。对于网络路径,可以使用PureWindowsPath处理UNC路径,或使用专门库:
# UNC路径(Windows)unc_path = PureWindowsPath(r"\\server\share\file.txt")# 特殊设备可能需要使用os模块import osos.stat("/dev/null")
八、总结与延伸学习
8.1 核心要点回顾
通过今天的深度解析,我们全面掌握了pathlib模块的四大核心优势:
  1. 面向对象设计:路径是智能对象而非普通字符串
  2. 直观的API:使用/运算符拼接,属性直接访问
  3. 跨平台透明:自动处理不同系统的路径差异
  4. 内置丰富操作:文件读写、目录管理一站式解决
8.2 实战项目建议
想要真正掌握pathlib?尝试完成以下实战项目:
  1. 项目配置管理系统:使用pathlib管理多环境配置文件,实现安全路径解析
  2. 日志轮转工具:开发自动化的日志归档和清理系统
  3. 批量文件处理器:实现图片格式转换、文档重命名等批量操作
  4. 跨平台部署脚本:编写在不同操作系统上都能正确运行的部署工具
8.3 延伸学习路径
pathlib是Python现代化生态的重要组成部分,要继续深入:
  1. 进阶方向
    • shutil:高级文件操作,如复制、压缩、归档
    • tempfile:临时文件和目录管理
    • watchdog:文件系统事件监控
  2. 实战书籍推荐
    • 《Python标准库》第10章:文件与目录访问
    • 《流畅的Python》第18章:文件系统路径
    • 《Effective Python》第72条:用pathlib代替os.path
  3. 开源项目学习
    • 查看Django、Flask等框架如何使用pathlib
    • 学习pandas、numpy等科学计算库的文件处理
    • 研究现代Python项目的路径处理最佳实践
8.4 最后的话
pathlib模块代表了Python语言现代化的发展方向——从函数式编程向面向对象编程的演进,从低层次字符串操作向高层次抽象的发展。
记住:优秀的Python程序员不是记住所有函数名,而是掌握现代化的编程范式。pathlib就是你从"传统Python"迈向"现代Python"的重要一步。
拥抱pathlib,告别路径操作的烦恼,让你的Python代码更加优雅、安全、可维护!

下一篇预告:明天我们将探索logging模块,学习如何构建专业的日志管理系统,让你的应用监控和故障排查更加高效。敬请期待!

本文为"Python与AI智能研习社"公众号原创文章,转载请注明出处。关注公众号,获取更多Python技术干货!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-28 18:08:54 HTTP/2.0 GET : https://f.mffb.com.cn/a/483573.html
  2. 运行时间 : 0.294542s [ 吞吐率:3.40req/s ] 内存消耗:4,681.05kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=0bc375039fb50701946dc304bca30529
  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.000461s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000564s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000269s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000309s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000563s ]
  6. SELECT * FROM `set` [ RunTime:0.004241s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000749s ]
  8. SELECT * FROM `article` WHERE `id` = 483573 LIMIT 1 [ RunTime:0.019066s ]
  9. UPDATE `article` SET `lasttime` = 1774692534 WHERE `id` = 483573 [ RunTime:0.007592s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.001315s ]
  11. SELECT * FROM `article` WHERE `id` < 483573 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.002264s ]
  12. SELECT * FROM `article` WHERE `id` > 483573 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.005882s ]
  13. SELECT * FROM `article` WHERE `id` < 483573 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.072646s ]
  14. SELECT * FROM `article` WHERE `id` < 483573 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.038113s ]
  15. SELECT * FROM `article` WHERE `id` < 483573 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.056302s ]
0.300407s