One - One Code All

Blog Content

python 遍历日期

Python   2019-12-31 20:04:01

python遍历日期,可以采用日历calendar


也可以简单点,直接当前日期加1.

import datetime

start = '2016-06-01'
end = '2017-01-01'

datestart = datetime.datetime.strptime(start, '%Y-%m-%d')
dateend = datetime.datetime.strptime(end, '%Y-%m-%d')

while datestart < dateend:
    datestart += datetime.timedelta(days=1)
    print datestart.strftime('%Y-%m-%d')



上一篇:mac下常用编辑器
下一篇:TinyMCE功能强大,所见即所得的富文本编辑器

The minute you think of giving up, think of the reason why you held on so long.