Python – How to get the time a file was last modified in Python?


Assuming the file exists (using os.path.exists(filename) to first make sure that it does), how do I display the time a file was last modified? This is on Linux if that makes any difference.

Best Solution

>>> import os
>>> f = os.path.getmtime('test1.jpg')
>>> f

since the beginning of (epoch)