import time #字符串转化为时间戳 def str_to_timeStamp(str): '''字符串格式为:2017-11-24 17:30:00''' timeStruct = time.strptime(str, "%Y-%m-%d %H:%M:%S") timeStamp = int(time.mktime(timeStruct)) return timeStamp #当前时间转化为字符串 def now(): # 获得当前时间时间戳 now = int(time.time()) # 转换为其他日期格式,如:"%Y-%m-%d %H:%M:%S" timeStruct = time.localtime(now) strTime = time.strftime("%Y-%m-%d %H:%M:%S", timeStruct) return strTime
python常用时间换算
猜你喜欢
转载自www.cnblogs.com/cynthia59/p/8920739.html
今日推荐
周排行