import datetime
1)#str -> datetime对象,(datetime对象之间可加减,date[0]为str)
datetime.datetime.strptime(date[0], '%Y-%m-%d')
2)#datetime ->str,(date为datetime对象)
date.strftime("%Y-%m-%d")
3)#取前一天(today为datetime对象)
yesterday = today + timedelta(days = -1)
4)#获取两日期之间所有日期
time=[(datetime.datetime.strptime(date[0], '%Y-%m-%d') + datetime.timedelta(days=i)).strftime("%Y-%m-%d")
for i in range((datetime.datetime.strptime(date[-1], '%Y-%m-%d') - datetime.datetime.strptime(date[0],'%Y-%m-%d')).days)]