【问题标题】:Python: How to get the created date and time of a folder? [duplicate]Python:如何获取文件夹的创建日期和时间? [复制]
【发布时间】:2011-11-29 17:13:27
【问题描述】:

可能重复:
How to get file creation & modification date/times in Python?

我想获取文件夹的创建日期和时间。无论如何在python中可以做到这一点?

谢谢

【问题讨论】:

  • 问题已回答here。看看;-)。
  • 还有一件事我想问一下,例如我在 25.08.2011 01:58:00 创建了一个名为“file”的文件夹。当我将此文件夹复制到其他目录时,它的创建日期和时间发生了变化。所以,即使将文件夹复制到其他目录,我如何才能获得 2011 年 8 月 25 日 01:58:00 的日期和时间。 :(

标签: python directory


【解决方案1】:

您可以使用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)

【讨论】:

  • 还有一件事我想问一下,例如我在 25.08.2011 01:58:00 创建了一个名为“file”的文件夹。当我将此文件夹复制到其他目录时,它的创建日期和时间发生了变化。所以,即使将文件夹复制到其他目录,我如何才能获得 2011 年 8 月 25 日 01:58:00 的日期和时间。 :(
  • 感谢 Unix 和 Windows 在 st_ctime 方面的区别
猜你喜欢
  • 2011-12-21
  • 1970-01-01
  • 2021-01-18
  • 2017-12-16
  • 2010-09-19
  • 2011-10-16
  • 2014-06-08
  • 2010-09-12
  • 2016-03-21
相关资源
最近更新 更多