본문 바로가기
파이썬

파이썬 timedelta를 부동 소수점으로 변환

by º기록 2020. 12. 24.
반응형

두 개의 날짜 시간을 빼서 timedelta 객체를 얻었습니다. 추가 계산을 위해이 값이 부동 소수점으로 필요합니다. All that I've found enables the calculation with floating-points, but the result 여전히 timedelta 객체입니다.

time_d = datetime_1 - datetime_2
time_d_float = float(time_d)

작동하지 않습니다.

 

해결 방법

 


time_d_float = time_d.total_seconds()

 

참조 페이지 https://stackoverflow.com/questions/21414639

 

 

반응형

댓글