python中的字符串预处理

2024-10-05 12:28:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用了urllib.parse.unquotehtml.unescape来预处理我的字符串,但出乎意料的是,我的字符串中有'\xa0'和'\u200e'字符,是否有python函数来为我做最后两个替换,以防我的字符串中有更多这样的字符?你知道吗

# res = res.replace("%20", "") 
res = urllib.parse.unquote(res)
# res = res.replace(' ', ' ')
res = html.unescape(res)
res = res.replace('\xa0', '')
res = res.replace('\u200e', '')

Tags: 函数字符串parsehtmlresurllib字符replace

热门问题