Total_seconds Method Of Python Timedelta Class

Method Name:

total_seconds

Method Signature:

total_seconds()

Overview:

Returns the duration represented by the timedelta object as number of seconds.

Parameters:

None

Example:

import datetime

 

# Create a time duration of one day

timeDuration = datetime.timedelta(days=1)

print("Time duration:%s"%(timeDuration))

print("Time duration as seconds:%s"%(timeDuration.total_seconds()))

 

Output:

Time duration:1 day, 0:00:00

Time duration as seconds:86400.0


Copyright 2023 © pythontic.com