import datetime
startTime=datetime.datetime.strptime('2019-05-22 11:34:50', "%Y-%m-%d %H:%M:%S")#(形式要对应)
endTime= datetime.datetime.strptime('2019-05-02',"%Y-%m-%d")
# 相减得到秒数、小时、天数
seconds = (endTime- startTime).seconds
hours=(endTime- startTime).hours
day=(endTime- startTime).days