You can use the os.stat
method and retrieve the last modification time using st_mtime
attribute. Here's an example code block to achieve this:
main.py359 chars12 lines
In this code block, we first import the os
module. We then set the directory_path
variable to the path of the directory we want to check. We then use the os.stat
method to get the stat_result
object for the directory. We retrieve the last modification time using the st_mtime
attribute and store it in last_modified_time
variable. Finally, we use the time
module to format the last_modified_time
into a human-readable format and print the result.
gistlibby LogSnag