UnicodeEncodeError:'ascii'编解码器无法在位置 32 中编码字符 u'\u2019':序号不在范围内(128)



我有一个字符串列表,下面给出:

[u'Any subscription charges to avail this facility',
 u'credited into the beneficiaryu2019s account',
 u'funds have been credited in the beneficiaryu2019s account',
 u'Can I reuse VPA']

字符串 (\u2019( 中有一些 unicode 字符表示 ('( 标点符号。请让我知道如何将其删除为创建错误。我使用以下代码删除但不起作用:

for x in mylist:
  x.encode('ascii','ignore')
  new_list.append(x)

但它返回具有 unicode 字符的相同列表。请帮忙

您不会将编码值追加到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']

相关内容

最新更新