2014-07-14 61 views
-2

我有興趣從互聯網上下載.jpg文件。 我想知道一個函數或任何讓我從python控制檯下載文件。 所以我想途中會有或多或少那樣:Python:如何通過它從互聯網上下載圖像URL

pythondonwloadfunction(URLofthefile, rootwheresavethedonwloadedfile) 
+0

可能重複[?我如何使用下載文件通過HTTP的Python(http://stackoverflow.com/questions/22676 /怎麼辦,我下載-A-文件過的HTTP使用的Python) – sebastian

回答

0
import requests 
with open('img.jpg', 'wb') as f: 
    f.write(requests.get('<image_url>').content)