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 248 views
1 answer 133 views
1 answer 116 views
116 views asked Aug 14, 2023 by avibootz
1 answer 197 views
1 answer 185 views
185 views asked Jun 17, 2016 by avibootz
...