结合datetime.date和datetime.time对象的Python方法 [英] Pythonic way to combine datetime.date and datetime.time objects
本文介绍了结合datetime.date和datetime.time对象的Python方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个表示同一事件实例的对象-一个保存日期,另一个保存该事件的时间,我想创建一个datetime对象.
I have two objects that represent the same event instance --- one holds the date, the other the time of this event, and I want to create a datetime object.
由于不能简单地添加日期和时间对象(调用失败):
Since one can't simply add date and time objects (following call fails):
datetime.date(2011, 01, 01) + datetime.time(10, 23)
推荐答案
它位于返回
datetime.datetime(2011, 1, 1, 10, 23)
这篇关于结合datetime.date和datetime.time对象的Python方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文