擅长:python、mysql、java
<p>如果需要使用run(),可以这样做:</p>
<pre><code>with settings(
hide('warnings', 'running', 'stdout', 'stderr'),
warn_only=True
):
command = 'ls -l backups'
output = run(command)
for line in output.splitlines():
do_stuff(line)
</code></pre>
<p>对于local(),有一个更简单的解决方案:</p>
<pre><code>command = 'ls -l backups'
output = local(command, capture=True)
for line in output.splitlines():
do_stuff(line)
</code></pre>
<p>我希望有帮助。</p>