赞
踩
参数timestamp
时间戳
返回值
def time_format(self, timestamp): '''时间格式化方法''' time_array = time.localtime(timestamp) week = { '0': '星期日', '1': '星期一', '2': '星期二', '3': '星期三', '4': '星期四', '5': '星期五', '6': '星期六' } if time_array.tm_mon < 10: tm_mon = '0'+str(time_array.tm_mon) else: tm_mon = time_array.tm_mon if time_array.tm_mday < 10: tm_mday = '0' + str(time_array.tm_mday) else: tm_mday = time_array.tm_mday if time_array.tm_hour < 10: tm_hour = '0'+ str(time_array.tm_hour) else: tm_hour = time_array.tm_hour if time_array.tm_min < 10: tm_min = '0'+ str(time_array.tm_min) else: tm_min = time_array.tm_min if time_array.tm_sec < 10: tm_sec = '0'+ str(time_array.tm_sec) else: tm_sec = time_array.tm_sec return f'{time_array.tm_year}年 {tm_mon}月 {tm_mday}日, {week[str(time_array.tm_wday)]}, {tm_hour}:{tm_min}:{tm_sec}'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。