2014-12-05 85 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