File Modification Time प्राप्त करना
File के Modification Time को प्राप्त करने के लिए, आप os.path.getmtime(path) का उपयोग कर सकते हैं। यह Cross-Platform Supported है।
उदाहरण
>>> import os
>>> print(os.path.getmtime('my_file.txt'))
1505928275.3081832
Return किया गया Value Float होता है जो Seconds में Time को Represent करता है (Epoch के बाद से)। Human-Readable Format में Convert करने के लिए:
>>> import os, time
>>> mtime = os.path.getmtime('my_file.txt')
>>> print(time.ctime(mtime))
Mon Oct 23 18:01:25 2017
संबंधित Functions:
os.path.getatime(path)- Last Access Timeos.path.getctime(path)- Creation Time (Windows) या Metadata Change Time (Unix)