简体   繁体   English

Windows 文件夹结构中的“访问”时间和“修改”时间有什么区别?

[英]What's the difference between 'access' and 'modified' times in Windows folder structure?

When I access the folder using os.path.getmtime(folder_path) , it does not return the modified time of a file.当我使用os.path.getmtime(folder_path)访问文件夹时,它不会返回文件的修改时间。 os.path.getatime(folder_path) returns the correct last modified time instead. os.path.getatime(folder_path)返回正确的最后修改时间。

On Windows, a folder's modified time is the time when the folder was last updated, not when a file in the folder was last updated.在 Windows 上,文件夹的修改时间是文件夹最后一次更新的时间,而不是文件夹中文件的最后一次更新时间。

When you create a file in a folder, getmtime(folder) and getatime(folder) are both updated.当您在文件夹中创建文件时, getmtime(folder)getatime(folder)都会更新。

When you edit an existing file in a folder, only getatime(folder) is updated, not getmtime(folder) .当您编辑文件夹中的现有文件时,只会更新getatime(folder) ,不会更新getmtime(folder)

When you read an existing file in a folder, only getatime(folder) is updated, not getmtime(folder) .当您读取文件夹中的现有文件时,只会更新getatime(folder) ,不会更新getmtime(folder)

To find when the latest file was updated in a folder, neither getatime(folder) nor getmtime(folder) will help.要查找文件夹中最新文件的更新时间, getatime(folder)getmtime(folder)都无济于事。 You need to loop through the files under the folder and use getmtime(each_file_in_folder) .您需要遍历文件夹下的文件并使用getmtime(each_file_in_folder)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM