python time comparison

import datetime
d1 = datetime.datetime.strptime('2015-03-05  17:41:20', '%Y-%m-%d %H:%M:%S')
d2 = datetime.datetime.strptime('2015-03-02 17:41:20', '%Y-%m-%d %H:%M:%S')

D1 IF> D2:
  Print 'D1 is relatively large'

the else:
  Print 'relatively large D2'

Source: https://www.cnblogs.com/cssdongl/p/6729120.html

 Wherein the strptime ( '2015-03-05 17:41:20', '% Y-M-% D%% H:% M:% S' ) of the identification combination can be marked red custom modifications

As the strptime ( '2015-03-05 --- 17:41:20', '% Y-M-% D% --- % H:% M:% S') that is modified according to the date format to be identified can

Guess you like

Origin www.cnblogs.com/kaibindirver/p/11058295.html