📌  相关文章
📜  带日期的列表推导 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:01.886000             🧑  作者: Mango

代码示例1
from datetime import datetime, timedelta
today = datetime.utcnow().date()
ct = datetime(today.year, today.month, today.day) # current_timestamp
time_intervals = []
while ct.hour <= 23 and today.day == ct.day:
  ct = ct + timedelta(minutes=10)
  time_intervals.append('%02d:%02d' % (ct.hour, ct.minute))
sorted_time_intervals = (sorted(time_intervals))