Python:如何获取文件夹的创建日期和时间?

11 投票
1 回答
37420 浏览
提问于 2025-04-17 03:34

可能重复的问题:
如何在Python中获取文件的创建和修改日期/时间?

我想要获取一个文件夹的创建日期和时间。有没有办法在Python中做到这一点?

谢谢

1 个回答

24

你可以使用 os.stat 这个功能来获取这些信息。

os.stat(path).st_mtime      // time of most recent content modification,
os.stat(path).st_ctime      // platform dependent; time of most recent metadata change on Unix, or the time of creation on Windows)

撰写回答