Encode Python list to UTF-8

前端 未结 2 1911
花落未央
花落未央 2020-12-03 05:46

I have a python list that looks like that:

list = [u\'a\', u\'b\', u\'c\']

Now I want to encode it in UTF-8. Therefore I though I should us

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 06:05

    >>> items =  [u'a', u'b', u'c']
    >>> [x.encode('utf-8') for x in items]
    ['a', 'b', 'c']
    

提交回复
热议问题