python string 到date object

 

 string 到date object:

1 datetime.datetime.strptime("2013-03-18 09:00","%Y-%m-%d %H:%M")

date之间的比较: 存在datetime下的timedelta类

delta = datetime.timedelta(days,seconds,totalseconds)

d1 = datetime.datetime(year,month,day,hour,minute,second)

d2 = datetime.datetime(year,month,day,hour,minute,second)

all those follow operations are available:

 d1 - d2 > delta ?

 d1 - delta > d2?

it's very useful design and very helpful for programmers.

原文地址:https://www.cnblogs.com/harveyaot/p/2975900.html