T2 = fields.Float()
date = fields.Date()
例如,如果T2 = 09:00 和日期= 12/09/2017
结果应该是12/09/2017 09:00
答案 0 :(得分:2)
你可以将T2转换为str并将两者结合起来
T2= "09,00"
date = datetime.date(2017,9,12)
date_str = date.strftime('%d/%m/%Y')
print date_str
date_str += T2
print date_str
print datetime.datetime.strptime(date_str, '%d/%m/%Y%H,%M')
12/09/2017
12/09/201709,00
2017-09-12 09:00:00
或者如果t2是浮点型
T2= 8.5
date = datetime.date(2017,9,12)
print datetime.datetime.fromordinal(date.toordinal()) + datetime.timedelta(seconds=T2*3600)
2017-09-12 08:30:00