Running Bash commands in Python

前端 未结 10 1632
礼貌的吻别
礼貌的吻别 2020-11-21 05:16

On my local machine, I run a python script which contains this line

bashCommand = \"cwm --rdf test.rdf --ntriples > test.nt\"
os.system(bashCommand)
         


        
10条回答
  •  逝去的感伤
    2020-11-21 05:44

    It is possible you use the bash program, with the parameter -c for execute the commands:

    bashCommand = "cwm --rdf test.rdf --ntriples > test.nt"
    output = subprocess.check_output(['bash','-c', bashCommand])
    

提交回复
热议问题