menu Chancel's blog
rss_feed
Chancel's blog
时来天地皆同力

Python3递归获取所有文件

作者:Chancel Yang, 时间:2021 Jun 15, 阅读:40

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

测试版本:Python3.6.9

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]])

还没有可以显示的留言...
[[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)]]