0
我有一个简单的代码:如何简化此代码?
results = mongo.group(
key = [ 'test','id' ],
....
)
temp_hash = {}
for result in results:
if temp_hash.has_key(result['test']):
temp_hash[result['test']] = int(temp_hash[result['test']]) + 1
else:
temp_hash[result['test']] = 1
如何使用MongoDB的唯一逻辑简化这个代码?