根无关的文件路径生成
filepaths的Python项目详细描述
目的
filepaths模块旨在简化python脚本中的文件路径导航。它对于遍历目录中的许多文件特别有用。在
使用
安装
pipinstallfilepaths
示例
^{pr2}$选项
file=None: for default behavior pass in __file__
depth=0: how many levels up up from __file__ to start the walk down
ignore_hidden=True: whether or not to include hidden files/paths
alt_path=False: if desired, specify an absolute path to another directory instead of file=__file__
说明
根对象存储信息以构建所需目录和路径的字符串。paths()
方法返回文件、目录及其路径的嵌套字典,作为键的值。{cd1>需要更新时,{cd1>可以再次调用。在
.paths()
方法返回一个addict dictionary。此字典继承标准dictionary类;可以使用root[data][files]
或{['files', 'dirs', 'path', filepaths']
。在
关键字'files', 'dirs', 'path',
和'filepaths'
是为字典保留的:如果在任何子目录中存在具有这些名称的目录,则将引发错误。在
上述键的值如下:
root.example.path
以字符串形式返回{}的绝对路径。在 root.example.dirs
返回example/
中的子目录列表。在root.example.files
返回example/
中每个文件的文件名列表(字符串)。在root.example.filepaths
以字符串形式返回example/
中每个文件的绝对路径列表。在
- 项目
标签: