0
This is the best one so farPythonの:私はstackoverflowの上の多くの質問を見てきましたが、答えのどれもシンプルでエレガントな方法を与えない、ダウンロード
ためにプログレスバーを追加します。
link = "http://download.thinkbroadband.com/10MB.zip"
file_name = "test"
with open(file_name, "wb") as f:
print('Downloading: {}'.format(file_name))
response = requests.get(link, stream=True)
total_length = response.headers.get('content-length')
if total_length is None:
f.write(response.content)
else:
dl = 0
total_length = int(total_length)
for data in response.iter_content(chunk_size=4096):
dl += len(data)
f.write(data)
done = int(50 * dl/total_length)
sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50-done)))
sys.stdout.flush()
ファイルをダウンロードしたときに詳細を取得できますか?これまでの質問には簡単な答えはありません。
引数がないのであれば、これを使用したくない場合は、別のものを示唆するのは難しいでしょう(おそらくそれを使用したくないかもしれません)。 – DonGru
私の言い直した質問です。リンクからダウンロードしてください。 – Varun