You can use the os.path.getatime()
function to retrieve the last access time of a file. Here's an example implementation:
main.py234 chars10 lines
In the above example, filename
should be replaced with the path to your JSON file. The os.path.getatime()
function returns the last access time of the file in seconds since epoch, which is then converted to a human-readable format using the datetime
module's fromtimestamp()
function. The resulting string is printed to the console.
gistlibby LogSnag