Operation check
Raspberry Pi2 + raspbian
http://qiita.com/7of9/items/b35747318a251247a249 Continued.
I want to get a string in yyyymmdd format from the date of the file.
Reference http://ja.pymotw.com/2/time/ Reference http://docs.python.jp/2/library/time.html
import os.path
import time
filepath = "/home/pi/BYOP/send.txt"
mddt = time.ctime(os.path.getmtime(filepath))
print mddt
parsed = time.strptime(mddt)
yyyymmdd = time.strftime("%Y%m%d", parsed)
print yyyymmdd
result
Mon Mar 7 07:18:45 2016
20160307
Recommended Posts