我有一个字符串列表,我想隐藏列表字符串到unicode。我正在使用Python 3.6。
corpus
['love song',
'cooki monster definit medal gold card mcdonald',
'c start cup',
'c',
'h help bc cooki moster gott help',
'cooki monster get diabet',
'lll']
“但是neet语料库是unicode”
corpus
['love song',
u'cooki monster definit medal gold card mcdonald',
u'c start cup',
'c',
u'h help bc cooki moster gott help',
u'cooki monster get diabet',
'lll']
答案 0 :(得分:3)
我认为你需要这样,
print [unicode(val,'utf-8') for val in l]
[u'love song', u'cooki monster definit medal gold card mcdonald', u'c start cup', u'c', u'h help bc cooki moster gott help', u'cooki monster get diabet', u'lll']
注意:为python 2版本提供的答案 根据Austin的评论,默认情况下,Literal字符串在Python 3中是unicode。因此您不需要在外部进行转换。