python 时间字符串 转时间

import datetime
dd = '20190320091316'


ti = datetime.datetime.strptime(dd,"%Y%m%d%H%M%S")

print(ti) 2019-03-20 09:13:16

dd = '2019-0320091316'


ti = datetime.datetime.strptime(dd,"%Y-%m%d%H%M%S")

print(ti) 2019-03-20 09:13:16

detester = '2017-01-01 12'
date = datetime.datetime.strptime(detester,'%Y-%m-%d %H')

print(date) 2017-01-01 12:00:00

你可能感兴趣的:(python)