擅长:python、mysql、java
<p>我就是这么做的:</p>
<pre><code>car = [ {'model':'ferrari', 'color': 'red', 'price':1200},
{'model':'lamborgini', 'color': 'blue', 'price':2000},
{'model':'ferrari', 'color': 'yellow', 'price':1000},
{'model':'ferrari', 'color': 'yellow', 'price':500} ]
newcar = []
for c in car:
new = True
for n in newcar:
if c['model']==n['model']:
if c['color']==n['color']:
if c['price'] < n['price']:
n['price'] = c['price']
new = False
if new:
newcar.append(c)
</code></pre>
<p>而<code>newcar</code>变量将存储最便宜的。我用你的箱子测试了一下,效果很好。你知道吗</p>