'utf8'编解码器无法解码位置0的字节0xd0:无效的连续字节 [英] 'utf8' codec can't decode byte 0xd0 in position 0: invalid continuation byte

查看:740
本文介绍了'utf8'编解码器无法解码位置0的字节0xd0:无效的连续字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在html文档中有以下文本:

I've the following text in an html document:

<a href="#">�'ам интересна информация</a>

我正在使用以下表达式提取文本:

and I'm using the following expression for extracting the text:

row.xpath("string(./td[@class='col2 td-tags']/h3/a/text())")

此表达式适用于简单的英语,但对于上述字符串,则会引发此错误:

This expression works fine for simple english, but for the above string it throws this error:

'utf8' codec can't decode byte 0xd0 in position 0: invalid continuation byte


推荐答案

在HTML中,& #xxx未在文档编码中指定字节;

In HTML, &#xxx does NOT specify a byte in the document encoding; it's ALWAYS a unicode codepoint.

因此,您不能将UTF-8放入这样的HTML中。

Thus, you can't put UTF-8 into an HTML like that.

这篇关于'utf8'编解码器无法解码位置0的字节0xd0:无效的连续字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆