import requests,re,os
with open(r'd:\图片地址列表.txt','r') as f:
urll=f.read()
urll=urll.split('\n')
for url in urll:
s=re.match(r'^http://[^/]+(.+)$',url).group(1)
s=s.replace('/','\\')
res=requests.get(url)
img=res.content
imgname=f'd:\\shufatu{s}'
os.makedirs(os.path.dirname(imgname), exist_ok=True)
with open(imgname,"ab") as f:
f.write(img)
print("end")
Traceback (most recent call last):
File "F:\Program Files\JetBrains\PyCharm Community Edition 2021.1.2\jbr\bin\F\PY\PycharmProjects\pythonProject\TU8.py", line 8, in <module>
s = re.match(r'^http://[^/]+(.+)$', url).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
进程已结束,退出代码为 1