擅长:python、mysql、java
<p>这里docs和pipes(<code>|</code>)是shell的属性。如果要逐字运行命令,请使用<code>shell=True</code>:</p>
<pre><code>from subprocess import check_call
check_call(r"""IFS= read -d '' text <<EOF
~|||-:this is text:-|||~
EOF
echo "${text}" | sed -e 's/\([[:punct:]]\)//g' | text2wave -scale 1 -o sound.wav
""", shell=True)
</code></pre>
<p>作为<a href="https://stackoverflow.com/questions/27875757/how-should-subprocess-be-used-for-commands-featuring-here-documents-and-multiple#comment44153099_27875757">@tripleee said</a>,可以用Python实现部分甚至整个命令。在</p>