擅长:python、mysql、java
<p>正如其他人所建议的,使用<a href="http://boto3.readthedocs.io/en/latest/reference/services/s3.html" rel="nofollow">Boto3 S3</a>库来获得您想要的。但如果你坚持要<code>subprocess</code>,请尝试:</p>
<pre><code>subprocess.check_output(['aws', 's3', 'ls', 's3://path/to/my/bucket/12434', '--recursive', '--human-readable', '--summarize'])
</code></pre>
<p>或者</p>
<pre><code>subprocess.call(['aws', 's3', 'ls', 's3://path/to/my/bucket/12434', '--recursive', '--human-readable', '--summarize'])
</code></pre>
<p>并以此为基础。</p>