赞
踩
class Path(object):
a,b,c = 0,0,0
l = []
for i in range(0,10):
p = Path()
p.c = random.randint(0,100)
l.append(p)
l.sort(key=lambda Path: Path.c) #对c不降序排序
dd = {1:3,2:9,3:2}
for i in dd.items():
print(i[0],i[1])
dd = {1:3,2:9,6:2}
a = min(dd, key=dd.get) #a为最小值的key
print("key = ",a, ", value = ",dd[a])
运行结果如下
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。