1. import datetime
2. string 转 datetime
str = '2017-09-04'
date_time = datetime.datetime.strptime(str,'%Y-%m-%d')
3. dateime 转 string
str = date_time.strftime('%Y-%m-%d')
1. import datetime
2. string 转 datetime
str = '2017-09-04'
date_time = datetime.datetime.strptime(str,'%Y-%m-%d')
3. dateime 转 string
str = date_time.strftime('%Y-%m-%d')