在 python 中可以使用內建的 urllib 函式庫來處理 URL 請求,也有內建的方法可以直接將檔案儲存到本機中:
文章撰寫中...請稍後...
import urllib.request
url = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png"
local_path = "image1.png"
try:
urllib.request.urlretrieve(url, local_path)
print("檔案下載成功")
except Exception as e:
print(f"下載失敗:{e}")
文章撰寫中...請稍後...
留言
張貼留言
如果有任何問題、建議、想說的話或文章題目推薦,都歡迎留言或來信: a@ruyut.com