【发布时间】:2015-02-19 06:24:45
【问题描述】:
如果文件存在,我使用以下代码获取文件的修改日期:
if os.path.isfile(file_name):
last_modified_date = datetime.fromtimestamp(os.path.getmtime(file_name))
else:
last_modified_date = datetime.fromtimestamp(0)
有没有更优雅/更简洁的方式?
【问题讨论】:
-
我相信这回答了你的问题。 stackoverflow.com/questions/237079/…