ValueError:未转换的数据保持:00:00:00

时间:2017-11-21 03:26:52

标签: python openerp

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

这是我的代码:

@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

2 个答案:

答案 0 :(得分:2)

您可以使用以下代码行 -

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

答案 1 :(得分:0)

将日期更改为大熊猫日期:

ImportError: cannot import name 'CUDF_INSTALLED' from 'xgboost.compat' (/opt/anaconda3/lib/python3.8/site-packages/xgboost/compat.py)

Time object e.g `a = pd.to_datetime(df['date']).apply(lambda x: x.date())