我有 1 个列表“name_list”。
name_list=['Name:Bill,Age:28,Height:6.1', 'Name:Dona,Age:23,Height:6.1','Name:Bill,Age:22,Height:6.1', 'Name:Shelly,Age:24,Height:7']
1)我想用常见数据对列表进行排序。例如输出应该是这样的:
out=['Name:Bill,Age:28,Height:6.1', 'Name:Bill,Age:22,Height:6.1']
2)我想用 Max 对列表进行排序。年龄。例如,如果我想查看谁的年龄最大输出应该是这样的。
out=['Name:Bill,Age:28,Height:6.1']
这是我到目前为止所做的:
name_list=['Name:Bill,Age:28,Height:6.1', 'Name:Dona,Age:23,Height:6.1','Name:Bill,Age:22,Height:6.1', 'Name:Shelly,Age:24,Height:7']
out = filter(lambda x:'Name:Bill' in x and 'Height:6.1' in x,list)