我在我的GitHub回购处有一个压缩文件。我想把它加载到我的Google文件中。我有它的网址,它可以像https://raw.githubusercontent.com/rehmatsg/../master/...zip一样加载
我使用这种方法将文件下载到Google Colab中。
from google.colab import files
url = 'https://raw.githubusercontent.com/user/.../master/...zip'
files.download(url)但我知道这个错误
FileNotFoundError Traceback (most recent call last)
<ipython-input-5-c974a89c0412> in <module>()
3 from google.colab import files
4
----> 5 files.download(url)
/usr/local/lib/python3.7/dist-packages/google/colab/files.py in download(filename)
141 raise OSError(msg)
142 else:
--> 143 raise FileNotFoundError(msg) # pylint: disable=undefined-variable
144
145 comm_manager = _IPython.get_ipython().kernel.comm_manager
FileNotFoundError: Cannot find file: https://raw.githubusercontent.com/user/.../master/...zip在Google中的文件是临时的,所以我不能每次上传它。这就是我想在我的项目的GitHub回购中托管文件的原因。将文件下载到Google的正确方法是什么?
发布于 2021-10-02 19:00:02
假设GitHub repo https://github.com/lukyfox/Datafiles包含有两个压缩文件digits.zip和digits_small.zip的文件夹数字。要从Google会话存储中下载并解压缩GitHub回购文件(不是整个回购或文件夹,而是digits.zip),请执行以下操作:
!wget命令和复制的地址一起下载,使用!unzip将文件解压缩到会话存储中:!wget https://github.com/lukyfox/Datafiles/raw/master/digits/digits.zip
!unzip /content/digits.zip
还可以在下载或指定解压缩数据的文件夹名后重命名该文件。
您可能会注意到,可下载地址与zip文件地址略有不同。事实上,应该足够用raw替换blob,以便为任何zip文件获得正确的地址。
发布于 2021-05-01 04:08:37
使用"wget“bash命令。只需打开Github项目并转到下载为zip选项(右上)。然后,复制url并使用"wget“命令。
!wget https://github.com/nytimes/covid-19-data/archive/refs/heads/master.zip
!unzip /content/master.zip
祝好运。
发布于 2021-03-06 14:16:55
您可以这样做来克隆整个存储库。
!git clone https://personalaccesstoken@github.com/username/reponame.git这将创建一个名为reponame的文件夹,如果您有许多文件要下载,它非常方便。personalaccesstoken允许访问私有存储库。
https://stackoverflow.com/questions/66504637
复制相似问题