12345678910111213a1 = "2019-5-10"# 先转换为时间数组timeArray = time.strptime(a1, "%Y-%m-%d")# 转换为时间戳timeStamp = int(time.mktime(timeArray))dt = datetime.fromtimestamp(timeStamp)# 当前时间timeStamp = time.time()dt2 = datetime.fromtimestamp(timeStamp)a = dt2 - dtb = dt - dt2print(dt2 - dt)print(dt - dt2)