擅长:python、mysql、java
<p>您的<code>i</code>就是键;您必须查找<code>data['url'][i]</code>才能获得嵌套字典。你知道吗</p>
<p>可以使用<code>dict.iteritems()</code>(Python 2)或<code>dict.items()</code>(Python 3)嵌套循环:</p>
<pre><code>for url, items in data.iteritems():
for item, value in items.iteritems():
print url, item, value['bytes']
</code></pre>
<p>如果计划编写CSV,请使用<a href="https://docs.python.org/2/library/csv.html" rel="nofollow">^{<cd5>} module</a>:</p>
<pre><code>import csv
with open('output.csv', 'wb') as outfh:
writer = csv.writer(outfh)
for url, items in data.iteritems():
for item, value in items.iteritems():
writer.writerow([url, item, value['bytes']])
</code></pre>