How to get the last update date of a python file

Asked

Viewed 1,549 times

-1

I would like to know how I can get the full date (day/month/year and time/minute/second) of the last update of an excel file?

1 answer

1

As discussed in How to check which latest file in a Python folder? you can use the property st_mtime of the archive:

from pathlib import Path

diretorio = Path('.')
arquivo = diretorio/'data.txt'

print(arquivo.stat().st_mtime)

That will give you the timestamp of the last modification, then just convert it to date with the module datetime

Browser other questions tagged

You are not signed in. Login or sign up in order to post.