python - 无论如何,我可以在 Google colaboratory 中下载该文件吗?

标签 python python-3.x jupyter-notebook google-colaboratory

我正在通过此代码实验室在 Google Colaboratory 中尝试 tensorflow, 我需要下载'http://download.tensorflow.org/example_images/flower_photos.tgz ' 此文件用于完成实验。

如何下​​载文件。有没有办法上传 tar 文件而不在我的机器上下载它。

这个方法我试过了

import urllib
testfile = urllib.URLopener()
testfile.retrieve("http://randomsite.com/file.gz", "file.gz")

这不起作用,也找不到 wget。任何人请告诉我如何做到这一点。

最佳答案

可能更简单:使用 !wget,例如,使用以下命令执行单元格:

!wget https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png

将文件保存到 VM 的本地文件系统。 (注意前导的 !。这是将此行作为 shell 命令执行的信号。)

关于python - 无论如何,我可以在 Google colaboratory 中下载该文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49576657/

相关文章:

python - 获取系统 ping 的输出而不打印到控制台

python - 自动重新寻址引用对象的所有变量

python - pcolorfast 上的 matplotlib MemoryError

python - 试图在按住 tkinter 按钮时保持功能持续运行

python - 在 JupyterNotebook 图中并排显示 Pandas DataFrame 和 Matplotlib

pandas - 在 Google Colabs 中何处/如何安全存储 API key ?

python - 如何在Python中打印缺失值的列名和缺失值的数量?

python - 从键值对元组列表中获取计数最少的项的键 - Python

python - YouTube 数据 API : breaking a nextPageToken while loop if quota limit is reached?

python - 用简单的 Python 脚本测试计算机处理速度