小编use*_*406的帖子

Python 嵌套列表替换字符串中的 unicode 字符

尝试替换或删除此列表中的字符串以插入到不允许它们的数据库中

info=[[u'\xa0Buffalo\u2019s League of legends ...', '2012-09-05'], [u' \xa0RCKIN 0 - 1 WITHACK.nq\xa0  ', u'\xa0Buffalo\u2019s League of legends ...', '2012-09-05']]
Run Code Online (Sandbox Code Playgroud)

我用了这个代码

info = [[x.replace(u'\xa0', u'') for x in l] for l in info]
info = [[y.replace('\u2019s', '') for y in o] for o in info]
Run Code Online (Sandbox Code Playgroud)

第一行有效,但第二行无效,有什么建议吗?

python unicode replace

2
推荐指数
1
解决办法
1738
查看次数

标签 统计

python ×1

replace ×1

unicode ×1