Convert timedelta to floating-point

后端 未结 5 2104
攒了一身酷
攒了一身酷 2020-12-13 08:17

I got a timedelta object from the subtraction of two datetimes. I need this value as floating point for further calculations. All that I\'ve found enables the calculation wi

5条回答
  •  眼角桃花
    2020-12-13 09:01

    If you needed the number of days as a floating number you can use timedelta's days attribute

    time_d = datetime_1 - datetime_2
    number_of_days = float(time_d.days)
    

提交回复
热议问题