擅长:python、mysql、java
<p>这是我用过的一个又快又脏的方法。在</p>
<pre><code>def run_cpp_thing(parameters):
proc = subprocess.Popen('mycpp' + parameters,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
so, se = proc.communicate()
# print se # the stderr stream
# print so # the stdio stream
# I'm going to assume so =
# "1 2 3 4 5"
# Now parse the stdio stream.
# you will obvious do much more error checking :)
# **updated to make them all numbers**
return [float(x) for x in so.next().split()]
</code></pre>