1 import time 2 import datetime 3 4 5 #函数定义 6 def getTimeNow(): 7 return datetime.datetime.now() 8 def getYesterDay(): 9 return getTimeNow() + datetime.timedelta(days=-1) 10 def getTimeByStamp(stamp): 11 temp_time = time.localtime(int(str(stamp)[0:10])) 12 str_1 = time.strftime("%Y-%m-%d %H:%M:%S", temp_time) 13 return datetime.datetime.strptime(str_1,"%Y-%m-%d %H:%M:%S")
标签:-%,常用,return,函数,python,datetime,str,time,def From: https://www.cnblogs.com/212s/p/16992590.html