can't compare datetime.datetime to datetime.date

前端 未结 6 2033
野趣味
野趣味 2020-12-05 12:20

I have the following code and am getting the above error. Since I\'m new to python I\'m having trouble understanding the syntax here and how I can fix the error:

<         


        
6条回答
  •  Happy的楠姐
    2020-12-05 13:12

    Assuming start is a datetime, Use it like this:

    if not start or date < start.date(): start = date
    

    I don't think there is a need to convert date to datetime in python, as you can just do the opposite and compare.

    Or else you have other methods to create a new datetime by using the date to convert and time at 00:00.

提交回复
热议问题