Pylint错误消息:"E1101:模块'lxml.etree'没有'strip_tags'成员'" [英] Pylint Error Message: "E1101: Module 'lxml.etree' has no 'strip_tags' member'"
问题描述
我第一次针对个人项目尝试使用 lxml 和python,并且尝试使用etree从一些源代码中剥离标签.strip_tags().
I am experimenting with lxml and python for the first time for a personal project, and I am attempting to strip tags from a bit of source code using etree.strip_tags().
由于某种原因,我不断收到错误消息:"E1101:模块'lxml.etree'没有'strip_tags'成员'."
For some reason, I keep getting the error message: "E1101: Module 'lxml.etree' has no 'strip_tags' member'".
我不确定为什么会这样.
I'm not sure why this is happening.
这是我代码的相关部分:
Here's the relevant portion of my code:
from lxml import etree
...
DOC = etree.strip_tags(DOC_URL, 'html')
print DOC
有什么想法吗?
谢谢.
推荐答案
The reason for this is that pylint by default only trusts C extensions from the standard library and will ignore those that aren't.
由于lxml不是stdlib的一部分,因此您必须手动将其列入白名单.为此,请在终端中导航到项目的目录,并为pylint生成一个rcfile:
As lxml isn't part of stdlib, you have to whitelist it manually. To do this, navigate to the directory of your project in a terminal, and generate an rcfile for pylint:
$ pylint --generate-rcfile > .pylintrc
然后,打开该文件,然后将lxml添加到白名单中,如下所示:
Then, open that file and add lxml to the whitelist like so:
extension-pkg-whitelist=lxml
之后,所有有关lxml的E1101错误都将消失.
After that, all E1101 errors regarding lxml should vanish.
这篇关于Pylint错误消息:"E1101:模块'lxml.etree'没有'strip_tags'成员'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!