python - How to get the value from a timedelta? -
when sqlalchemy returns:
{u'age': datetime.timedelta(12045),}
how 12045? i've tried str()
, strftime()
, , bunch of others, nothing works.
from docs, use .total_seconds()
length of timedelta. note timedelta you've provided showing days value, timedelta includes seconds , microseconds well. if want days, use .days
.
age = datetime.timedelta(12045) print(age.total_seconds()) # 1040688000.0 print(age.days) # 12045, not full value represented delta
Comments
Post a Comment