Python学习笔记 --- 循环遍历时间区间

# -*- coding:utf-8 -*-
import datetime
__author__ = 'yangxin'


def main():
    begin = datetime.date(2017,9,10)
    end = datetime.date(2017,9,20)
    for i in range((end - begin).days+1):  
        day = begin + datetime.timedelta(days=i)  
        print str(day)

if __name__ == '__main__':
    main()



Python学习笔记 --- 循环遍历时间区间_第1张图片

你可能感兴趣的:(Python,Object-Oriented,Programming)