Python-去掉(转换)字符串中的-Unicode-子串

从网页上爬下来的字符串带了好多的\u开头的字符串,比如

"The \u201cStrawberry Search Radar\u201d\r\n \r\n\r\n- 

现在想让这些 \u201c, \u201d显示为正常的字符串字形,只需要将字符串转为bytes类型,再用bytes类型的decode方法即可去掉,比如:

str = "The \u201cStrawberry Search Radar\u201d\r\n \r\n\r\n- "
# 重点是decode方法的第二个参数选 ignore
str_clr = bytes(str, encoding='utf-8').decode('utf-8', 'ignore')

# 输出
'The “Strawberry Search Radar”\r\n \r\n\r\n- '

参考

https://docs.python.org/zh-cn/3/howto/unicode.html