美文网首页
python替换字符串中unicode字符

python替换字符串中unicode字符

作者: 时间之外的故事 | 来源:发表于2019-05-16 11:47 被阅读0次

    爬取网站时在html文档中出现unicode字符比如"\u002F"。

    使用字符串replace方法替换Unicode字符

    s = '\u002F/something'
    s = s.replace(r'\u002F', '/')
    

    关键要使用原生字符串,避免'\u002F'转义。

    相关文章

      网友评论

          本文标题:python替换字符串中unicode字符

          本文链接:https://www.haomeiwen.com/subject/cogbaqtx.html