You can use the os.path.getmtime()
function to get the last modified timestamp of a file, and then convert it to a human-readable date format using the datetime
module. Here's an example code:
main.py223 chars9 lines
This code will print something like:
main.py64 chars2 lines
Note that the fromtimestamp()
function returns a datetime
object, which you can format as a string using various methods.
gistlibby LogSnag