1 def get_time(self): 2 ''' 3 @author : Cong 4 @Email : 624420781@qq.com 5 @描 述 : 生产时间列表 6 ''' 7 # 生成本日时间列表 8 i = datetime.datetime.now() 9 today = datetime.date.today() 10 date = [str(hour).zfill(2) + ':00' for hour in range(0, i.hour + 1)] 11 date_time = [str(today) + ' ' + str(hour).zfill(2) for hour in range(0, i.hour + 1)] 12 # 生成本周时间列表 13 allweek = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] 14 nowweek = i.weekday() 15 week = allweek[nowweek:] + allweek[0:nowweek] 16 week_time = [str(today - datetime.timedelta(days=8 - w)) for w in range(1, 8)] 17 # 生成本月时间列表 18 month = i.strftime('%Y-%m-') 19 day = [str(d) + '号' for d in range(1, i.day)] 20 day_time = [month + str(d).zfill(2) for d in range(1, i.day)] 21 return {'date': date, 'date_time': date_time, 'week': week, 'week_time': week_time, 'day': day, 22 'day_time': day_time}