码迷,mamicode.com
首页 > 编程语言 > 详细

python技巧:日期的遍历

时间:2014-12-04 00:41:24      阅读:4928      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   color   sp   for   on   div   

import datetime

def 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)
    #

bubuko.com,布布扣

python技巧:日期的遍历

标签:style   blog   http   ar   color   sp   for   on   div   

原文地址:http://www.cnblogs.com/ChenKeng/p/4141794.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!