python timedelta seconds code example

Example 1: python timedelta

from datetime import timedelta 
tomorrow = datetime.today() + timedelta(days = 1)

Example 2: python convert datetime.timedelta into seconds

a_timedelta = datetime.timedelta(seconds=24*60*60)

timedelta_seconds = a_timedelta.total_seconds()

print(timedelta_seconds)
OUTPUT
86400.0

Example 3: python timedelta to seconds

import datetime
datetime.datetime.timestamp(datetime.timedelta(hours=1, days=2, seconds=1000)).total_seconds()