python> Get file last modified date> mddt = time.ctime (os.path.getmtime (filepath))> Mon Mar 7 07:18:45 2016

Operation check


Raspberry Pi2 + raspbian

We are considering using the last modified date of the file send.txt to set the message posting date of the message station.

You can get the last modified date from the file path as follows.

160308_fileLastModificationDate.py


import os.path
import time

filepath = "/home/pi/BYOP/send.txt"
mddt = time.ctime(os.path.getmtime(filepath))
print mddt

result


Mon Mar  7 07:18:45 2016

Find out how to read the value of [Date] from here.

Recommended Posts

python> Get file last modified date> mddt = time.ctime (os.path.getmtime (filepath))> Mon Mar 7 07:18:45 2016
[Python] Get the last updated date of the website
Get the update date of the Python memo file.
[Python3] Get date diff
Get date in Python
Get date with python
Spit out a list of file name, last modified date and character code in python3
Set the last modified date of the child file to the modified date of the parent directory