擅长:python、mysql、java
<p>是的,如果你这样做的话,你必须在每次通过后重置D1,否则指针保持不变,你将D2中的所有关键点指向同一个D1。以下是如何解决这个问题:</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>