gpt4 book ai didi

python - 值错误: unconverted data remains: 00:00:00

转载 作者:行者123 更新时间:2023-12-01 02:25:56 27 4
gpt4 key购买 nike

我在转换日期时间时遇到问题。

这是我的代码:

@api.multi
def action_confirm(self):
if picking.state not in ['cancel', 'draft']:
for schedule_delivery in sorted_key:

print "line 105: ", schedule_delivery
dup_picking = picking.copy()
if shift == "afternoon":
date_object = datetime.strptime(schedule_delivery, '%Y-%m-%d')
print "Line 146", date_object
# raise EnvironmentError
tanggal = datetime.strftime(date_object, "%Y-%m-%d") + ' 06:00:00'
print "Line 145", tanggal
dup_picking.min_date = tanggal
else:
dup_picking.min_date = schedule_delivery

错误:

    date_object = datetime.strptime(schedule_delivery, '%Y-%m-%d')
File "/usr/lib/python2.7/_strptime.py", line 328, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: 00:00:00

最佳答案

您可以使用这行代码-

date_object = datetime.strptime(str(schedule_delivery), '%Y-%m-%d %H:%M:%S')

关于python - 值错误: unconverted data remains: 00:00:00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47404678/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com