一个扩展的、更强大的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为什么Scanner类不像println方法那样使用重载的概念   java Jersey:接受枚举请求参数的整数   java如何在EclipseKepler中安装Hibernate?   java在修补servlet中的jsp文件时获取NullPointerException   java“addScript”在HSQL中是否有最大记录计数?   java Maven使用@Ignore运行单元测试   java是args[0],args[1]变量吗?   java Swing JScrollPane溢出   java与Facebook Graph Api更新机制的集成,无需实时更新   java矩形在多边形内?   java Netty句柄AnnotatedConnectionException   java Springboot JPA不自动生成表   java如何在后台或睡眠模式下采样加速度计数据   java为什么RocketMQ DefaultMQProcuderImpl在成功发送消息的情况下调用updateFaultItem   java在对象数组中计算最小值,然后在另一个计算中使用它   java重缩放JFrame内容   如何使用Netbeans在java中输入泰米尔语(swing组件)?