Convert date to datetime in Python

后端 未结 10 2474
感动是毒
感动是毒 2020-11-28 17:10

Is there a built-in method for converting a date to a datetime in Python, for example getting the datetime for the midnight of the giv

10条回答
  •  余生分开走
    2020-11-28 17:44

    You can use the date.timetuple() method and unpack operator *.

    args = d.timetuple()[:6]
    datetime.datetime(*args)
    

提交回复
热议问题