How do I get the modified date/time of a file in Python?
How do I get the modified date/time of a file in Python? [duplicate]
os.path.getmtime(filepath)
or
os.stat(filepath).st_mtime
@endolith: https://mcmap.net/q/45386/-how-do-i-get-file-creation-and-modification-date-times says "os.path.getmtime() is made for this, and simpler." –
Rowden
Formated:
import time
print time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fname)))
ISO-like fmt:
"%Y-%m-%d %I:%M:%S %p"
–
Sharp © 2022 - 2024 — McMap. All rights reserved.