Convert datetime.time into datetime.timedelta in Python 3.4

后端 未结 2 1819
执念已碎
执念已碎 2020-12-06 17:51

I am trying to convert two \"durations\", however I am currently receiving a TypeError due to one being a datetime.timedelta and one being a

2条回答
  •  抹茶落季
    2020-12-06 18:10

    Here's one solution I've found, though it's not necessarily efficient:

    import datetime
    x = datetime.timedelta(hours=x.hour, minutes=x.minute, seconds=x.second, microseconds=x.microsecond)
    

    Where x is a datetime.time object.

提交回复
热议问题