你可以使用Python中的requests库来下载图片。以下是一个简单的示例代码:
import requestsdef download_image(url, file_path):response = requests.get(url)if response.status_code == 200:with open(file_path, 'wb') as file:file.write(response.content)print(f"Image downloaded successfully to {file_path}")else:print("Failed to download image")# 用法示例url = "https://example.com/image.jpg"file_path = "image.jpg"download_image(url, file_path)在上面的示例中,我们定义了一个download_image函数来下载图片。你只需要传入图片的URL和保存的文件路径作为参数调用该函数即可下载图片。
上一篇:elasticsearch分片迁移的原理是什么
下一篇:python的pyinstaller怎么使用
python









