首页 服务端 python 正文

module lxml has no attribute etree错误处理

long 2020-05-04 09:06 爬虫 人气2953

问题代码:

import lxml
selector = lxml.etree.HTML(resp.text)

代码报错:AttributeError: module 'lxml' has no attribute 'etree'

处理方法:

使用 lxml.etree之前要import:

import lxml.etree