一个扩展的、更强大的pathlib。

pathlib-mate的Python项目详细描述


Documentation Statushttps://travis-ci.org/MacHu-GWU/pathlib_mate-project.svg?branch=masterhttps://codecov.io/gh/MacHu-GWU/pathlib_mate-project/branch/master/graph/badge.svghttps://img.shields.io/pypi/v/pathlib_mate.svghttps://img.shields.io/pypi/l/pathlib_mate.svghttps://img.shields.io/pypi/pyversions/pathlib_mate.svghttps://img.shields.io/pypi/dm/pathlib_mate.svghttps://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social
https://img.shields.io/badge/Link-Document-blue.svghttps://img.shields.io/badge/Link-API-blue.svghttps://img.shields.io/badge/Link-Source_Code-blue.svghttps://img.shields.io/badge/Link-Install-blue.svghttps://img.shields.io/badge/Link-GitHub-blue.svghttps://img.shields.io/badge/Link-Submit_Issue-blue.svghttps://img.shields.io/badge/Link-Request_Feature-blue.svghttps://img.shields.io/badge/Link-Download-blue.svg

欢迎使用pathlib_mate文档

pathlib是不同操作系统中一个非常棒的库处理路径。从python3.4开始它就被添加到标准库中。pathlib_mate提供了广泛的方法和属性,使pathlib更加强大和用户友好。

功能:

方便的属性访问器

>>>p=Path("/Users/username/test.py").>>>p.abspath/Users/username/test.py>>>p.basenametest.py>>>p.fnametest>>>p.ext.py>>>p.dirnameusername>>>p.dirpath/Users/username>>>p.size1500>>>p.size_in_text1.46KB>>>p.create_datetimedatetime(2018,1,15,8,30,15)>>>p.md5415f12f07a7e01486cc82856621e05bf>>>p.sha256d51512cb0ac71484c01c475409a73225d0149165024d7aac6d8e655eedf2c025>>>p.sha5127882fc375840cafa364eaf29dc424645b72fcdbe61fc3326c5afd98e70f696e4f390e0e3f159eac2cb60cedc0992ef7b5f8744a4481911e914a7c5b979e6de68

强大的路径搜索功能

>>>p=Path("/Users/username/Documents")>>>forpathinp.select_file(recursive=True)...>>>forpathinp.select_file(recursive=False)...>>>forpathinp.select_dir(recursive=True)...>>>forimage_fileinp.select_by_ext([".jpg",".png"])...>>>forbig_fileinp.select_by_size(min_size=1000000)...>>>forvideo_fileinp.select_video():...# You can customize the filter anyway you want>>>defpy_filter(p):return".py"==p.ext.lower()>>>forpy_fileinp.select_file(py_filter):...

eazy使用文件/目录操作

>>>p=Path("/Users/username/Documents/Readme.txt")# mutate>>>p.change(new_ext=".md")/Users/username/Documents/Readme.md>>>p.change(new_fname="Tutorial")/Users/username/Documents/Tutorial.txt>>>p.change(new_basename="README.rst")/Users/username/Documents/README.rst>>>p.change(new_dirname="Downloads")/Users/username/Downloads/Readme.txt>>>p.change(new_dirpath="/User/username/Downloads)/Users/username/Downloads/Readme.txt>>>p.change(new_abspath="/Users/username/Downloads/Readme.txt")/Users/username/Downloads/Readme.txt# copy>>>p.moveto(new_ext=".md",makedirs=True)# cut>>>p.copyto(new_ext=".md",makedirs=True)# delte>>>p.remove()

功能强大的生产工具

>>>p=Path("/Users/username/Documents/Github/pathlib_mate-project")>>>p.print_big_dir_and_big_file()...>>>p.file_stat(){"file":122,"dir":41,"size":619682}# file statistics, include sub folder>>>p.file_stat_for_all()# make an zip archive for the directory, auto naming>>>p.make_zip_archive()# make an zip archive for the directory, auto naming>>>p.backup()

安装

pathlib_mate在pypi上发布,所以您只需要:

$ pip install pathlib_mate

要升级到最新版本:

$ pip install --upgrade pathlib_mate

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Hibernate在实体映射中出现重复列   java如何用FTP目录填充JTree?   java无法解析引用本地ejbref。两个EJB模块之间的通信   java如何在主文件夹的文件和子文件夹中进行更改?   java如何在接到电话时“正确”发送短信?   java有没有一种方法可以在javafx的桌面浏览器中使用saml对用户进行身份验证   java如何通过命令行开始在eclipse中运行?   带有远程数据库的java安卓应用程序   java替换行输入。基于关闭标志的txt文件   爪哇科特林。如何将十进制数的结尾设置为零?   java AgentInitializationException:已加载代理JAR,但代理在尝试注入JAR文件时未能初始化   Java:nextInt()验证不起作用   垃圾收集使用Java9G1GC,系统。应用程序加载时未执行gc()。为什么?   java将Spring引导应用程序部署到Tomcat服务器   java在创建新方法的同时创建新对象,这怎么可能呢?   使用HFileOutputFormat2时发生java ClassCastException   java应用程序未从编辑文本中获取值,似乎正在跳过行