Is there anyway I can download the file in Google colaboratory?

后端 未结 2 635
说谎
说谎 2021-02-07 14:47

I am trying tensorflow in Google Colaboratory from this codelab, I need to download \'http://download.tensorflow.org/example_images/flower_photos.tgz\' this file to complete th

相关标签:
2条回答
  • 2021-02-07 14:49

    Possibly simpler: use !wget, e.g., executing a cell with the command:

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

    will save the file to the local filesystem of the VM. (Note the leading !. This is a signal to execute the line as a shell command.)

    0 讨论(0)
  • 2021-02-07 15:15

    Read the manual, they have good examples and explanations: urllib.request

    To download:

    >>> import os
    >>> import urllib.request
    >>> urllib.request.urlretrieve('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png', 'google.png')
    ('google.png', <http.client.HTTPMessage object at 0x7fba3c4cb908>)
    >>> os.listdir()
    ['google.png']
    

    To just check the content:

    >>> with urllib.request.urlopen('http://www.python.org/') as f:
    ...     print(f.read(300))
    
    0 讨论(0)
提交回复
热议问题