No of Days between two dates in python 2.4
This will w开发者_Python百科ork in python 2.6
from datetime import datetime
print (datetime.strptime('2008-12-31', "%Y-%m-%d")- datetime.strptime('2007-04-30',"%Y-%m-%d")).days
But in 2.4 shows following error
AttributeError: type object 'datetime.datetime' has no attribute 'strptime'
Thank you for all your Support.
from datetime import date from time import strptime
x= strptime('2008-12-31', "%Y-%m-%d")
y= strptime('2007-04-30', "%Y-%m-%d")
print (date(x.tm_year,x.tm_mon,x.tm_mday)- date(y.tm_year,y.tm_mon,y.tm_mday)).days
In Python 2.4 strptime is located in time module:
from time import strptime
See http://docs.python.org/release/2.4/lib/module-time.html
精彩评论