时光机
python 字符串和时间格式(datetime)相互转换import datetime
dd = '2019-03-17 11:00:00'dd = datetime.datetime.strptime(dd, "%Y-%m-%d %H:%M:%S")print(dd,type(dd))
dc = dd.strftime("%Y-%m-%d %H:%M:%S")print(dc,type(dc))
期末考试已结束,代码干起来
hello world
python 字符串和时间格式(datetime)相互转换
str转时间格式:import datetime
dd = '2019-03-17 11:00:00'
时间格式转str:dd = datetime.datetime.strptime(dd, "%Y-%m-%d %H:%M:%S")
print(dd,type(dd))
dc = dd.strftime("%Y-%m-%d %H:%M:%S")
print(dc,type(dc))
期末考试已结束,代码干起来
hello world