python os.system(“ command”)

时间:2019-01-20 19:01:58

标签: python escaping os.system

我想通过os.system(command)运行以下命令

echo '@include("acf/rows.php")' >>  ../functions.php

我似乎无法正确地将引号转义。我该怎么做?

1 个答案:

答案 0 :(得分:1)

os.system('echo \'@include(\"acf/rows.php\")\' >> ../functions.php')

非常感谢@ Tomothy32

更好:

with open("../functions.php", "a") as functions:
        functions.write("@import('acf/rows.php');")

感谢@deceze