How to get the last update date of a file in python [closed]

0

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

    
asked by anonymous 11.12.2018 / 18:35

1 answer

1

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

from pathlib import Path

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

print(arquivo.stat().st_mtime)

This will give you the timestamp of the last modification, so just convert it to date with the datetime

    
11.12.2018 / 18:52