擅长:python、mysql、java
<p>对于第一个案子</p>
<pre><code>old = {
'key[0]': 'value 0',
'key[1]': 'value 1',
'key[2]': 'value 2'
}
new = dict()
the_key = old.keys()[0].split("[")[0]
new[the_key] = list()
for key in old:
new[the_key].append(old[key])
print new
</code></pre>
<p>按<code>[</code>拆分旧字典键之一以获得真正的键。然后用这个键构造新的dict。我觉得这是一种不好的做法,但它很管用。所以你可以看看。在</p>