import requests
from lxml import etree
import os
if __name__ == "__main__":
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.56 "
}
url = "https://pic.netbian.com/4kmeinv/"
response = requests.get(url = url, headers = headers).text
# print(response)
tree = etree.HTML(response)
part_url = tree.xpath('//ul[@class="clearfix"]//img/@src') #
for a in part_url: # 这里的a无论取什么变量名都会提示前面已经定义,并且这段for语句会没作用,但不报错
a = "https://pic.netbian.com" + a
以上为全部代码...
然后idle中会有个警告
描述为:已重新声明上文定义的无用法的 'a'
检查信息: This inspection detects unconditional redeclarations of names without being used in between, like this:
def x(): pass
x = 2
It applies to function and class declarations, and top-level assignments.
a: Any
|