http://docs.python.org/library/operator.html#operator.attrgetter
from operator import attrgettermin_num = min(li,key=attrgetter('number'))
>>> li = [SpecialNumber(1), SpecialNumber(3), SpecialNumber(2)]>>> [i.number for i in li][1, 3, 2]>>> min_num = min(li,key=attrgetter('number'))>>> print min_num.number1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)