2011-10-03 74 views
2

可能重複:
How to get file creation & modification date/times in Python?Python:如何獲取文件夾的創建日期和時間?

我想獲得一個文件夾的創建日期和時間。有沒有辦法在Python中做到這一點?

謝謝

+0

此問題已回答[此處](http://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times-in-python)。一探究竟 ;-)。 – OnesimusUnbound

+0

謝謝你:--D – Ricky

+0

還有一件事我想問一下,例如我在2011年的25.08.2011 01:58:00創建了一個名爲「file」的文件夾。當我將該文件夾複製到其他目錄時,其創建的日期和時間將發生變化。因此,即使將該文件夾複製到其他目錄,如何在25.08.2011 01:58:00獲取日期和時間。 :( – Ricky

回答

7

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

謝謝你的人:-D – Ricky

+0

還有一件事我想問,例如我創建一個名爲「文件」的文件夾在25.08.2011在01:58:00。當我將該文件夾複製到其他目錄時,其創建的日期和時間已更改。因此,即使將文件夾複製到其他目錄,我如何在2011年5月25日01:58:00獲取日期和時間。:( – Ricky

相關問題