#!/data/xce/local//python/bin/python2.7
# -*- coding:utf-8 -*-
import os
# dateutil 庫的使用 日期按天循環(huán)
from datetime import date
from dateutil.rrule import rrule, DAILY
time_start = date(2016, 6, 1)
time_end = date(2016, 6, 15)
for dt in rrule(DAILY, dtstart=time_start, until=time_end):
print dt.strftime("%Y-%m-%d")
運行結(jié)果:
2016-06-01
2016-06-02
2016-06-03
2016-06-04
2016-06-05
2016-06-06
2016-06-07
2016-06-08
2016-06-09
2016-06-10
2016-06-11
2016-06-12
2016-06-13
2016-06-14
2016-06-15