【问题标题】:How to get field values from unicode[u'a', u'd'] in odoo10如何从 odoo10 中的 unicode[u'a', u'd'] 获取字段值
【发布时间】:2018-04-30 01:00:04
【问题描述】:

我想得到字符串形式的 unicode。为此,我的代码在这里:

@api.multi

    def _select_service_product(self):

        r = []

        for order in self.order_line:

            res = order.product_id.type_service

            r.append(res)

            self.services_infor = r

            l = self.services_infor

            print "test,,,", res, self.services_infor, l

services_infor = fields.Char(compute='_select_service_product')

现在终端显示:

test,,, d [False, u'a', u'd'] [False, u'a', u'd']

从这里我想要值 a,b

【问题讨论】:

    标签: python-2.7 list unicode openerp odoo-10


    【解决方案1】:
    x = u"['a', 'b']"
    # either you c an explicitly convert the unicode chars
    print str(x)
    output : "['a', 'b']"
    #use eval function to make the unicode list to original
    print eval(x)
    output: ['a','b']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多