【问题标题】:How can I get the created dates for all files in subdirectories [duplicate]如何获取子目录中所有文件的创建日期[重复]
【发布时间】:2020-06-30 16:41:12
【问题描述】:

我有一个子目录中的文件路径列表。如何找到每个文件路径的创建日期?我使用下面的代码使用 Python 获取每个子目录中的所有文件:

def find(pattern, path):
    result = []
    for root, dirs, files in os.walk(path):
        for name in files:
            if fnmatch.fnmatch(name, pattern):
                result.append(os.path.join(root, name))
    return result

find(pattern, Path)

【问题讨论】:

    标签: python os.walk


    【解决方案1】:

    尝试以下功能之一:

    os.path.getmtime(file_path)os.path.getctime(file_path)

    【讨论】:

    猜你喜欢
    • 2012-12-31
    • 2023-03-23
    • 2020-08-29
    • 1970-01-01
    • 2013-06-16
    • 2017-08-20
    • 2014-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多