def return_add_model_id(self, modelList):
func = lambda x: modify_idKeys(x)
model_id = self._id
def modify_idKeys(goods):
g = goods.copy()
for keys, value in goods.items():
if keys == '_id':
g[model_id] = value
return g
return list(map(func, modelList))
province_list = [{'name': '北京市', 'code': '11'}, \
{'name':'天津市','code':'12'},{'name':'河北省','code':'13'}]
remove_province_list = ['河北省']
list(filter(lambda x: x.get('name') not in remove_province_list \
and x.pop('code'), province_list))
a = list(map(lambda x, y : x*y, [1.2, 3, 5], [2, 4, 6]))
print(a)
a = reduce(lambda x,y:x+y,a)
print(a)
def toUpper(item):
return item.upper()
list(map(toUpper, ["hao", "chen", "coolshell"]))