Python 2.7 如何安排日期时间格式

Python 2.7 如何安排日期时间格式,python-2.7,odoo-8,openerp-7,odoo-9,Python 2.7,Odoo 8,Openerp 7,Odoo 9,我有两个字段,如下所示 > appo_date = fields.Date(string="Appointment Date") > appo_time = fields.Float(string="Appointment Time") appo_date_and_time = fields.Char(compute='_combine', string='Appointment Date/Time', arg=('appo_date','appo_time'), method

我有两个字段,如下所示

>  appo_date = fields.Date(string="Appointment Date")
>  appo_time = fields.Float(string="Appointment Time")
appo_date_and_time = fields.Char(compute='_combine', string='Appointment Date/Time', arg=('appo_date','appo_time'), method=True)
我连接了这两个字段

@api.multi
    def _combine(self):
        if self.appo_date and self.appo_time:
            self.appo_date_and_time = '%s  %f' % (self.appo_date, self.appo_time)
        elif self.appo_date:
            self.appo_date_and_time = str(self.appo_date)
        elif self.appo_time:
            self.appo_date_and_time = str(self.appo_time)
并在单独的字段中调用该函数,如下所示

>  appo_date = fields.Date(string="Appointment Date")
>  appo_time = fields.Float(string="Appointment Time")
appo_date_and_time = fields.Char(compute='_combine', string='Appointment Date/Time', arg=('appo_date','appo_time'), method=True)
这些字段在xml文件中被调用

<field name="appo_date"/>
<field name="appo_time"/>
<field name="appo_date_and_time"/>
以这种格式。我需要它
19/05/2016 9:00

如何做到这一点

您需要使用string对象的split函数

请尝试使用此代码

string_obj_name.split(' ')[0]
详情