student_info={ 15:{'jack','rose',}, 18:{'jj'}, 35:{'a','b','c','d'}, } age_counts = {}# 定义一个字典 key=age value=name的长度 for age in student_info: count = len(student_info[age]) age_counts[age] = count ''' age_counts={ 15:2, 18:1, 35:4, } ''' #计算最大的是哪个age result=max(age_counts,key=age_counts.get) print(result) ''' 35 '''
标签:get,max,age,35,key,counts From: https://www.cnblogs.com/haha1988/p/17529907.html