首页 > 代码库 > python技巧:日期的遍历

python技巧:日期的遍历

import datetimedef date_range(start_date,end_date):    for n in range(int((end_date-start_date).days)):        yield start_date+datetime.timedelta(n)                        start=datetime.datetime(2014,11,26,0,0,0)end=datetime.datetime(2014,12,2,0,0,0)for i in date_range(start, end):    print i.strftime(%Y%m%d)    #

python技巧:日期的遍历