python - 如何从数据框中的 URL 下载图像并使用存储在数据框中的特定 id 标记集合图像?
问题描述
df
我拥有的数据框有列['index', 'en_title', 'jp_title', 'en_description', 'jp_description', 'image_url', 'store_item_id']
,我想从列中的 url 下载图像'image url'
并用列中的数字标记它们'store_item_id'
。
到目前为止,我已经尝试过:
import requests
image_url = list(df["image_url"])
for img in image_url:
file_name = img.split('/')[-1]
print("Downloading file:%s"%file_name)
r = requests.get(img, stream=True)
# this should be file_name variable instead of "file_name" string
with open(file_name, 'wb') as f:
for chunk in r:
f.write(chunk)
它运行了,但我没有下载任何图像,而且我还没有弄清楚如何用'store_item_id'
.
解决方案
推荐阅读
- python - 使用双循环创建 DataFrame
- angular - Angular 6 - 共享模块中的自定义管道未导出
- angular - Angular 6:将数据添加到另一个组件后更新一个组件中的表
- tensorflow - “Tensorflow GPU”版本和 MX150 2GB GPU
- java - Spring Boot - 无法解决 Whitelabel 错误页面
- java - JTable 单元格中的格式编号
- c# - 使用 hololens 记录游戏对象
- kubernetes - 没有 hostPort 无法运行 Traefik 负载均衡器
- javascript - 只加载一张表
- css - 你如何用多个图像表达多个 CSS 类?