menu E4b9a6's blog
rss_feed
E4b9a6's blog
有善始者实繁,能克终者盖寡。

Python3递归获取所有文件

作者:E4b9a6, 创建:2021-06-15, 字数:465, 已阅:53, 最后更新:2021-06-15

这篇文章更新于 1225 天前,文中部分信息可能失效,请自行甄别无效内容。

Python3递归获取目录下的所有文件(含子目录内的所有文件)

测试版本:Python3.6.9

Python
import os

def get_list_by_folder(path):
    list_name = []
    for file in os.listdir(path):
        file_path = os.path.join(path, file)
        if not os.path.isdir(file_path):
            list_name.append(file_path)
        else:
            list_name.extend(GetListByFolder(file_path))
    return list_name

if __name__=='__main__':
    file_list = get_list_by_folder("./")
    print(file_list)

[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
gravatar
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]