擅长:python、mysql、java
<p>当使用<code>input</code>时,python2中的<code>raw_input</code>将<code>eval</code>字符串。如果使用<code>python3</code>运行脚本,它将按原样工作,因为<code>python2</code>将更改为<code>raw_input</code>。你知道吗</p>
<p>使用<code>check_call</code>通常是更好的方法,使用<code>with</code>打开文件。你知道吗</p>
<pre><code>import subprocess
with open('test_input') as input1:
subprocess.check_call(['python3', 'script.py'], stdin=input1)
</code></pre>