You can use the os.path.getmtime()
function to get the last modified time of a file, and then convert it to a human-readable format using the datetime
module.
Here's an example code snippet:
main.py251 chars10 lines
Note that os.path.getmtime()
returns the last modified time as a Unix timestamp, which represents the number of seconds since January 1, 1970. The datetime.fromtimestamp()
function converts this timestamp to a datetime
object, which can then be formatted using the strftime()
method.
gistlibby LogSnag