在python中执行shell命令有问题。下面是导致错误的代码的某些部分:
p = subprocess.Popen(["cat input.txt |apertium -d. kaz-morph|\
sed -e 's/\$\W*\^/$\n^/g'| cut -f2 -d'/'|cut -f1 -d '<'|\
awk '{print tolower($0)}'|sort -u>output.txt"], shell=True, stdout=f1)仍然收到错误:未终止的命令。
希望你能帮我,因为我十天都解决不了。
附注:对不起我的英语
发布于 2017-02-21 06:12:40
'\n'必须是'\\n',否则它将被解释为行中断,这将导致一个未终止的字符串"cat input.txt |apertium -d. kaz-morph|sed -e 's/\$\W*\^/$"。
或者,将字符串标记为raw:r"cat input.txt |apertium ...."。
https://stackoverflow.com/questions/42359867
复制相似问题