如何在datetime中增加一天?蟒蛇 [英] How to increment the day in datetime? Python

查看:76
本文介绍了如何在datetime中增加一天?蟒蛇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在datetime中增加一天?在python。

How to increment the day in datetime? In python.

for i in xrange(1,5)
    date=datetime.datetime(2003,8,i,12,4,5)
    print date

但是我需要经过几年?有任何想法吗?
应该更简单的方式....

But i need pass through years? Any ideas? Should be easyier way....

推荐答案

date = datetime.datetime(2003,8,1,12,4,5)
for i in range(5): 
    date += datetime.timedelta(days=1)
    print(date) 

这篇关于如何在datetime中增加一天?蟒蛇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆