可能是由于函数括号写错,或者哪里写的不够规范

错误代码如下:

title=li.xpath[".//a/@href"]

  

此时会报错:TypeError: 'method' object is not subscriptable

修改后:

title=li.xpath(".//a/@href")

  

正确。

相关文章: