python - Windows文件夹结构中的 'access'和 'modified'次有什么区别?

标签 python python-3.x windows

当我使用 os.path.getmtime(folder_path) 访问文件夹时,它不会返回文件的修改时间。 os.path.getatime(folder_path) 返回正确的上次修改时间。

最佳答案

在 Windows 上,文件夹的修改时间是文件夹最后更新的时间,而不是最后更新文件夹中文件的时间。

当您在文件夹中创建文件时,getmtime(folder)getatime(folder)均已更新。

当您编辑文件夹中的现有文件时,仅getatime(folder)已更新,而不是getmtime(folder) .

当您读取文件夹中的现有文件时,仅getatime(folder)已更新,而不是getmtime(folder) .

要查找文件夹中最新文件的更新时间,getatime(folder) 都没有。也不getmtime(folder)会有帮助的。需要循环遍历该文件夹下的文件,使用getmtime(each_file_in_folder) .

关于python - Windows文件夹结构中的 'access'和 'modified'次有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71792404/

相关文章:

python - 从URL上传Django ImageField

python - 如何在 python 中验证服务器的 ssl 证书?

python-3.x - Airflow 1.10 : sqlalchemy. orm.exc.NoResultFound:未找到 one() 的行

php - 如果您习惯在 Mac 上使用 TextMate,您会在 Windows 上使用哪个 PHP IDE?

Python 类作为对象

python - matplotlib:如何刷新 figure.canvas

python - 如何在 Python 上将列表的所有值导出到 csv

python-3.x - 如何修复 : ERR Protocol error: expected '$' , 得到 ' '

windows - LWP/IO::Socket::SSL 失败并返回 SSL3_GET_SERVER_HELLO:错误的密码

c - 在 cygwin 上使用 fscanf() 读取 "text"文件的行