### Python datetime 模塊之timedelta

timedalte 是datetime中的一個對象，該對象表示兩個時間的差值

1 millisecond = 1000 microseconds
1 minute = 60 seconds
1 hour = 3600 seconds

1 week = 7 days

0 <= microseconds < 1000000
0 <= seconds < 3600*24 (the number of seconds in one day)
-999999999 <= days <= 999999999

timedalte 有三個只讀屬性：

timedelta.min：負數最大時間差，相當於  timedelta(-999999999)。
timedelta.max：正數最大時間差，相當於  timedelta(days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999)。

timedelta.resolution：兩個時間的最小差值 相當於   timedelta(microseconds=1)。

```from datetime import date,timedelta
print(timedelta.max);#999999999 days, 23:59:59.999999
print(timedelta(days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999));#999999999 days, 23:59:59.999999

print(timedelta.min);#-999999999 days, 0:00:00
print(timedelta(-999999999));#-999999999 days, 0:00:00

print(timedelta.resolution);#0:00:00.000001
print(timedelta(microseconds=1));#0:00:00.000001```

timedelta.total_seconds()方法：返回該時間差 以秒為單位的值

```from datetime import datetime,date,timedelta
now = datetime.now();
nextDay = now + timedelta(days = 1);#增加一天后的時間
nextSecond = now + timedelta(seconds = 1);#增加一秒后的時間
span  = now - nextDay;#獲取時間差對象
print(now);
print(nextDay);
print(nextSecond);
print(span.total_seconds());#獲取時間差 以秒為單位```