How can I com开发者_Go百科pare two dates in python to determine if the second one is after the first one?
Hint: datetime.strptime()
def dateAfter(d1, d2):
    from datetime import date
    d1list = d1.split(".")
    day1 = int(d1list[0])
    month1 = int(d1list[1])
    year1 = int(d1list[2])
    d2list = d2.split(".")
    day2 = int(d2list[0])
    month2 = int(d2list[1])
    year2 = int(d2list[2])
    date1 = date(year1, month1, day1)
    date2 = date(year2, month2, day2)
    return date1 > date2
>>> dateAfter("13.12.2010", "08.12.2010")
True
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论