One - One Code All

Blog Content

python日期之计算两个日期相隔月数

Python   2011-11-06 15:05:11

python 计算两个日期之间相隔的月数:

>>> from dateutil import rrule
>>> import datetime
>>> from dateutil import rrule
>>> d1 = datetime.date(2010,8,30)
>>> d2 = datetime.date(2011,5,3)
>>> months = rrule.rrule(rrule.MONTHLY, dtstart=d1, until=d2).count()
>>> months
8



上一篇:python日期之计算两个日期相隔天数
下一篇:python获取10位和13位时间戳

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