I'd like to add some words in a file using python script. Here is my script(for which name is test.py
) and how I excute the script.
import os
some_python_words = "sys.path.insert(0, os.path.abspath('..'))\n"
scripts = "echo '%s' >> 'conf.py' " % (some_python_words)
os.system(scripts)
As I am execute in the terminal by python test.py
. What writes in my file is
sys.path.insert(0, os.path.abspath(..))
The single quotation ''
of ..
is gone. What should I do?