wget:无法解析google colab中的主机地址

时间:2020-09-19 05:44:27

标签: python-3.x google-colaboratory wget

以下命令在google colab中有效。

!wget -P "/content/drive/My Drive/data" ftp://speedtest.tele2.net/1KB.zip

它将下载数据。

但是,当我尝试下载多个文件时,

urls = ["ftp://speedtest.tele2.net/1KB.zip",
        "ftp://speedtest.tele2.net/512KB.zip"]

for url in urls:
  print (url)

  !wget -P "/content/drive/My Drive/data" url

发生以下错误:

wget: unable to resolve host address ‘url’ 

1 个答案:

答案 0 :(得分:1)

您需要在变量前加上$

urls = ["ftp://speedtest.tele2.net/1KB.zip",
        "ftp://speedtest.tele2.net/512KB.zip"]

for url in urls:
  print (url)

  !wget -P "/content/drive/My Drive/data" $url