有两千多个图片链接在excel里,想全下下来
是编程零基础 代码都是网上抄的
但还是报错了帮忙看看 感激不尽!
import os
from pathlib import Path
import pandas
import requests
xlsx = pandas.read_excel('./@avogado6_user_tweets.xlsx')
for index, row in xlsx.interrows():
name1 = row['UTC']
name2 = row['Text']
name = name1[3:4] + name1[6:7] + name1[9:10] + name2
url = row['Media URL1']
print(f'Downloading[{name2}]')
response = requests.get(url)
basename, ext = os.path.splitext(url)
filepath = Path(f'./download/{name}')
if not filepath.parent.exists():
filepath.parent.mkdir(parents=True)
with filepath.open('w+b') as fp:
fp.write(response.content)
报错内容如下:
Traceback (most recent call last):
File "C:\Users\Nico\PycharmProjects\pythonProject\main.py", line 8, in <module>
for index, row in xlsx.interrows():
File "C:\Users\Nico\PycharmProjects\pythonProject\venv\lib\site-packages\pandas\core\generic.py", line 5907, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'interrows'. Did you mean: 'iterrows'?
Process finished with exit code 1
感谢大家的帮助!(csdn的屏蔽词真多。)