2014-12-05 32 views

回答

2

docs開始,使用.total_seconds()來獲取timedelta的長度。請注意,您提供的timedelta顯示的是天數值,但timedelta也包含秒和微秒。如果您只想要這些日子,請使用.days

age = datetime.timedelta(12045) 
print(age.total_seconds()) # 1040688000.0 
print(age.days) # 12045, but not the full value represented by the delta