strptime

使用strptime来格式化字符串

datetime.datetime.strptime("2019-10-02", "%Y-%m-%d")
# datetime.datetime(2019, 1, 2, 0, 10)

timedelta

使用timedelta来进行计算天数

a = datetime.datetime.strptime("2019-10-02", "%Y-%m-%d")
b = datetime.datetime.strptime("2019-10-01", "%Y-%m-%d")
a - b
# datetime.timedelta(1)
(a - b).days
# 1
05-11 21:54