I want to receive November 30, 2015 as the string 20151130.
Reference SO
There are various methods, but it seems that it can be done by the following two methods.
http://ideone.com/i1SNzk
test.py
import datetime
today = datetime.date.today()
print today
print today.strftime("%Y%m%d")
print "{:%Y%m%d}".format(today)
result
Success time: 0.03 memory: 44680 signal:0
2015-11-30
20151130
20151130
.format () hesitates to use from the following two points.
.strftime () seems to be easier to remember.
Recommended Posts