擅长:python、mysql、java
<p>如果您运行<code>python -</code>。它将从<code>stdin</code>读取程序。这对于来自不同来源的任意长的python脚本非常有用</p>
<pre><code>python_source = `import csv,json
a=list()
for i in csv.DictReader(open('/Users/Astra/data_in/Data.csv', 'r')):
a.append(json.dumps(i))
b=dict(enumerate(a))
c=json.dumps(b, sort_keys=True, indent=4)
print(c)`
cmd := exec.Command("python", "-")
cmd.Stdin = strings.NewReader(python_source)
...
</code></pre>