我有一个字符串列表如下:
[u'Any subscription charges to avail this facility',
u'credited into the beneficiary\u2019s account',
u'funds have been credited in the beneficiary\u2019s account',
u'Can I reuse VPA']
字符串(\ u2019)中有一些unicode char表示(')标点符号。请让我知道如何删除此作为创建错误。我使用下面的代码删除但不起作用:
for x in mylist:
x.encode('ascii','ignore')
new_list.append(x)
但它返回与unicode字符相同的列表。请帮忙
答案 0 :(得分:0)
您没有将编码值附加到new_list。
for x in mylist:
new_list.append(x.encode('ascii','ignore'))
['Any subscription charges to avail this facility',
'credited into the beneficiarys account',
'funds have been credited in the beneficiarys account',
'Can I reuse VPA']