0
我有1個列表「name_list」。Python中的過濾器函數
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)
什麼'屬性'包含在你的'普通數據'? –
用戶輸入你想輸出爲':'姓名:比爾,年齡:28,身高:6.1','姓名:比爾,年齡:22歲,身高:6.1''? –