1.计算列表中有sex = f个字典的数量
list = [{'name':'Mike', 'sex':'m'}, {'name':'Rose', 'sex':'f'}] count = (p['sex'] == 'f' for p in list) print(sum(count))
1.计算列表中有sex = f个字典的数量
list = [{'name':'Mike', 'sex':'m'}, {'name':'Rose', 'sex':'f'}] count = (p['sex'] == 'f' for p in list) print(sum(count))