python error:‘gbk‘ codec can‘t encode character ‘\xa0‘ in position 389: illegal multibyte sequence

unicodedata.normalize("NFKD", unicode_str)



import unicodedata
text_string = BeautifulSoup(raw_html, "lxml").text
clean_text = unicodedata.normalize("NFKD",text_string)
print clean_text

REF:https://stackoverflow.com/questions/10993612/how-to-remove-xa0-from-string-in-python#:~:text=%5B%26xa0%26%5D%20is%20actually%20non-breaking%20space%20in%20Latin1%20%28ISO,could%20be%20represented%20by%201%20to%204%20bytes.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值