如何从odoo10中的unicode [u'a',u'd']获取字段值

时间:2017-11-16 13:08:47

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

我想获得字符串形式的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

1 个答案:

答案 0 :(得分:0)

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']