擅长:python、mysql、java
<p>这可能是因为您在for循环中引用了相同的dict D1。我认为您必须在每次迭代中创建新的dict。像这样:</p>
<pre><code>for n in range(3):
D1 = {}
D1['D1key1'] = pjson['jsonkey1'][n]['jsonkey4'] # Data1n
D1['D1key2'] = pjson['jsonkey2'][n]['jsonkey5'] # Data2n
D1['D1key3'] = pjson['jsonkey3'][n]['jsonkey6'] # Data3n
D2['%s%d' % ('D2key', n+1)] = D1
</code></pre>