Python中如何根据日期区间进行循环

=Start=

缘由:

学习、提高需要

正文:

参考解答:

python datetime for loop

import datetime
 
date1 = datetime.date(2017725)
date2 = datetime.date(2017818)
day = datetime.timedelta(days=1)
while date1 <= date2:
    print date1.strftime('%Y.%m.%d')
    date1 = date1 + day

&

如何用Bash确定每个月的英文缩写?
先给结果:
('Jan''Feb''Mar''Apr''May''Jun''Jul''Aug''Sep''Oct''Nov''Dec',)
再说方法:
for i in $(seq 0 11);do
    date -d "2017-01-01 + "$i" month" -R | awk '{print $3}'
done

https://ixyzero.com/blog/archives/3055.html

参考链接:

https://stackoverflow.com/questions/14288498/creating-a-loop-for-two-dates
https://stackoverflow.com/questions/1060279/iterating-through-a-range-of-dates-in-python
https://stackoverflow.com/questions/22907062/iterating-over-date-in-python

=END=

声明: 除非注明,ixyzero.com文章均为原创,转载请以链接形式标明本文地址,谢谢!
https://ixyzero.com/blog/archives/3573.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注