파이썬 3.6에서 Tqdm 모듈을 사용하여 진행률 표시 줄을 설정하려고했지만 중간에있는 것처럼 보입니다.파일을 다운로드 할 때 Tqdm을 사용하여 진행 막대 추가
내 코드는 다음
from tqdm import tqdm
import requests
import time
url = 'http://alpha.chem.umb.edu/chemistry/ch115/Mridula/CHEM%20116/documents/chapter_20au.pdf'
# Streaming, so we can iterate over the response.
r = requests.get(url, stream=True)
#Using The Url as a filename
local_filename = url.split('/')[-1]
# Total size in bytes.
total_size = int(r.headers.get('content-length', 0))
#Printing Total size in Bytes
print(total_size)
#TQDM
with open(local_filename, 'wb') as f:
for data in tqdm(r.iter_content(chunk_size = 512), total=total_size, unit='B', unit_scale=True):
f.write(data)
문제는, 즉 내가 삽입 할 때 다운로드 데이터를 표시하는 동안 진행률 표시 줄이 전혀로드하지 않습니다,하지만 난 chunk_size = 512
을 완전히 제거 할 때 chunk_size = 512
r.iter_content
에와 괄호를 비워두면 막대가 정확하게로드되지만 다운로드 속도는 끔찍합니다.
여기서 내가 뭘 잘못하고 있니?