Python日期与字符串互转

 

 

import datetime

#str -> date
detester = '2017-01-01'
date = datetime.datetime.strptime(detester,'%Y-%m-%d')


#date -> str
date = datetime.now()
detester = date.strftime('%Y-%m-%d')

 

posted @ 2018-07-17 15:53  ''竹先森゜  阅读(2224)  评论(0编辑  收藏  举报