<p>完全解决你的问题</p>
<pre><code>from collections import OrderedDict
lst1 = ['company1,AAA,7381.0 ', 'company1,BBB,-8333.0 ', 'company1,CCC, 3079.999 ',
'company1,DDD,5699.0 ', 'company1,EEE,1640.0 ', 'company1,FFF,-600.0 ',
'company1,GGG,3822.0 ', 'company1,HHH,-600.0 ', 'company1,JJJ,-4631.0 ',
'company1,KKK,-400.0 ']
lst2 =['company1,AAA,-4805.0 ', 'company1,ZZZ,-2576.0 ', 'company1,BBB,1674.0 ',
'company1,CCC,3600.0 ', 'company1,DDD,1743.998 ']
#Create an OrderedDict, this will ensure that the Order in the original
# List is maintained
out_dict = OrderedDict()
#Create a Dictionary out of the first List, Note the key is
#the company and product ID
for e in lst1:
key, _, value = e.strip().rpartition(",")
out_dict[key] = float(value)
#Now iterate through the next list
for e in lst2:
# Partition on company, productID and Value
key, _, value = e.strip().rpartition(",")
#Retrieve the value with the key with default '0'
#and add value from the new list
out_dict[key] = out_dict.get(key, 0) + float(value)
#Finally recreate the list from the dictionary
lst3 = [','.join(map(str, e)) for e in out_dict.iteritems()]
print lst3
</code></pre>