How to get access, modification and creation time of a text file in Python

1 Answer

0 votes
from os import path
from datetime import date

at = path.getatime("d:\data.txt")
mt = path.getmtime("d:\data.txt")
ct = path.getctime("d:\data.txt")

at = date.fromtimestamp(at)
mt = date.fromtimestamp(mt)
ct = date.fromtimestamp(ct)

print("access time: ", at)
print("modification time: ", mt)
print("creation time: ", ct)


'''
run:
 
access time:  2018-06-13
modification time:  2018-09-29
creation time:  2018-06-09

'''

 



answered Nov 14, 2018 by avibootz

Related questions

1 answer 363 views
1 answer 229 views
1 answer 235 views
235 views asked Aug 14, 2023 by avibootz
1 answer 295 views
1 answer 279 views
279 views asked Jun 17, 2016 by avibootz
...