【文件属性】:
文件名称:pyfilesystem2:Python的文件系统抽象层
文件大小:222KB
文件格式:ZIP
更新时间:2021-03-26 05:47:17
python filesystem-library filesystem zip ftp
PyFilesystem2
Python的文件系统抽象层。
文献资料
介绍
将PyFilesystem的FS对象视为Python的file对象的下一个逻辑步骤。 就像文件对象抽象一个文件一样,FS对象抽象整个文件系统。
让我们来看一个简单的代码示例。 以下函数使用PyFilesystem API来计算目录中Python代码的非空白行数。 它以递归方式工作,因此它将在所有子目录中找到.py文件。
def count_python_loc ( fs ):
"""Count non-blank lines of Python code."""
count = 0
for path in fs . walk . files ( filter = [ '*.py' ]):
with fs . open ( path ) as python_file :