不要使用os.system
。不推荐使用此方法,而推荐使用subprocess。从文档:“此模块旨在取代旧的几个模块和功能:os.system,os.spawn”
。
就像你的情况一样:
bashCommand = "cwm --rdf test.rdf --ntriples > test.nt"
import subprocess
process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
output, error = process.communicate()