我一直在使用此代码通过 Google Drive 安装 Colab 并通过粘贴下载 URL 来下载任何文件,但我注意到即使文件大小只有几兆字节也需要很长时间。有什么可以做的来改善它。
**First cell:**
from google.colab import drive
drive.mount('/content/gdrive')
root_path = 'gdrive/My Drive/'
**Second cell:**
import requests
file_url = "DOWNLOAD URL HERE"
r = requests.get(file_url, stream = True)
with open("/content/gdrive/My Drive/FILE NAME HERE", "wb") as file:
for block in r.iter_content(chunk_size = 1024):
if block:
file.write(block)
Run Code Online (Sandbox Code Playgroud)