【问题标题】:I want to use wget with variable for parameter我想使用带有变量的 wget 作为参数
【发布时间】:2021-08-17 04:00:07
【问题描述】:

我正在使用 google colaboratory,它给了我错误消息

File "<ipython-input-1-41d5736708c2>", line 14 wget --no-check-certificate foo -O bar ^ SyntaxError: invalid syntax

这是我的代码

foo = 'https://example.com'
bar = '/tmp/' + foo.rsplit('/')[-1]
wget --no-check-certificate foo -O bar

我阅读了整个教程视频,但每个人都使用 wget https://example.com 而不是 wget (variable) 是否可以将 wget 与定义的变量一起使用?

【问题讨论】:

  • Format your error messages with `message` so it can preserve line breaks.
  • 嗨,谢谢您的建议
  • When accessing variables in Bash, add dollar signs before their names. wget --no-check-certificate foo -O bar becomes wget --no-check-certificate $foo -O $bar

标签: python tensorflow google-colaboratory wget


【解决方案1】:

为命令插入变量:

!wget --no-check-certificate {foo} -O {bar}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    • 2020-12-18
    • 2012-04-05
    • 2021-08-06
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多