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')
相關文章
相關標籤/搜索