def download_image(url, filename): response = requests.get(url, stream=True) total_size = int(response.headers.get('content-length', 0)) block_size = 1024 wrote = 0 with open(filename, 'wb') as f: for data in tqdm(response.iter_content(block_size), total=math.ceil(total_size//block_size), unit='KB'): f.write(data) wrote = wrote + len(data) if total_size != 0 and wrote != total_size: print("Error: Failed to download the file completely.")
小黑屋|手機版|NoName Team 電腦資訊討論區 |網站地圖
GMT+8, 2026-3-9 06:59 , Processed in 0.098060 second(s), 21 queries .
Powered by Discuz! X3.4
© 2001-2017 Comsenz Inc.