【问题标题】:How do I convert this linux command to python string? [duplicate]如何将此 linux 命令转换为 python 字符串? [复制]
【发布时间】:2022-01-19 10:27:52
【问题描述】:

我有一个 linux 命令:

jq -r '."meta-version" |= "abc"' temp.json > folder1/folder2/abc.json

在终端上运行良好,但我想将其转换为 python 字符串并使用 python 脚本执行。我收到错误,如何将其转换为 python 字符串 例如:

var = "jq -r '."meta-version" |= "abc"' temp.json > folder1/folder2/abc.json"

【问题讨论】:

  • 可以使用三引号""" .... """

标签: python python-3.x string


【解决方案1】:

试试这个:

var = "jq -r '.\"meta-version\" |= \"abc\"' temp.json > folder1/folder2/abc.json"

【讨论】:

    猜你喜欢
    • 2019-10-21
    • 2012-11-27
    • 2014-12-15
    • 1970-01-01
    • 2013-02-28
    • 1970-01-01
    • 2023-01-04
    • 1970-01-01
    • 2017-12-01
    相关资源
    最近更新 更多