import time import datetime #获取当前的日期时间 n=datetime.datetime.now() print(n) #获取一个指定时间 da=datetime.datetime(2018,2,13,5,23,45) print(da) #日期转字符串 s1=d1.strftime("%Y-%m-%d %H%M%S") print(s1) #字符串转成日期 s2="2018/02/13 05:23:45" datetime.datetime.srtptime(s2,"%Y-%m-%d %H:%M:%S") print(d2,type(d2))
标签:-%,内置,23,python,s2,datetime,print,d2 From: https://www.cnblogs.com/datizi/p/16596563.html