Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ValueError:未转换的数据仍然存在:00:00:00_Python_Openerp - Fatal编程技术网

Python ValueError:未转换的数据仍然存在:00:00:00

Python ValueError:未转换的数据仍然存在:00:00:00,python,openerp,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()

我在转换日期和时间方面有问题

这是我的密码:

@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')

将日期更改为指定日期:

Time对象,例如'a=pd.to_datetime(df['date'])。应用(lambda x:x.date())


然后'date\u object=datetime.strtime(str(计划交付),'%Y-%m-%d')

您可以这样做,datetime.strtime(str(计划交付),'%Y-%m-%d'))