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

wget: unable to resolve host address in google colab

以下命令适用于 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’ 

您需要在变量前加上前缀 $

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