使用urllib.request.urlretrieve
时,我想知道是否有办法查看控制台中打印的下载状态以及文件大小等信息?
这是我正在测试的代码:
#!/usr/bin/env python3.5.2
import urllib.request
import os
# make sure to change the directory before you test the code
directory = r'C:\Users\SalahGfx\Desktop\Downloads'
url = 'https://upload.wikimedia.org/wikipedia/en/d/d8/C4D_Logo.png'
def get_name_path():
image_name = url.split('/')[-1]
return os.path.join(directory, image_name)
urllib.request.urlretrieve(url, get_name_path())
print('The Image has been downloaded!')