3
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!')
お返事ありがとうございます。私は今、それを行うことの背後にある論理を理解していますが、私は、urlopenがファイル名なしでurlを取ることを知っていますので、urlretrieveを置き換える唯一の方法ですか? – SalahGfx