擅长:python、mysql、java
<p>不知道什么变量与您的“启用”,但尝试下面</p>
<pre><code>from subprocess import check_output
datas = []
data = check_output("kapacitor list tasks | grep -i enabled")
print (data)
for i, j, k in data: # i,j,k are just three variables in example. Add more if needed.
datas.append((i,j),(k))
print (datas[0]) # prints (i,j)
</code></pre>
<p>对于其他类型的子进程命令,请检查SO问题:<a href="https://stackoverflow.com/questions/3791465/linux-command-line-call-not-returning-what-it-should-from-os-system">Linux command-line call not returning what it should from os.system?</a></p>