摘要:
Sorted函数 a = {6:2,8:0,1:4,-5:6,99:11,4:22} #a的类型为字典dict, a.items()表示以列表返回 print( sorted(a.items()) ) #根据key来排序print( sorted(a.items(),key=lambda x:x[1 阅读全文
posted @ 2017-07-28 11:45
细雨轻风
阅读(179)
评论(0)
推荐(0)
摘要:
摘自http://www.cnblogs.com/evening/archive/2012/03/29/2423554.html map(func, seq1[, seq2,…]) Python函数编程中的map()函数是将func作用于seq中的每一个元素,并将所有的调用的结果作为一个list返回 阅读全文
posted @ 2017-07-28 09:24
细雨轻风
阅读(625)
评论(0)
推荐(0)
摘要:
一般地: 转成列表:list() 转成字典:dict() 转成元组:tuple() 转成字符串:str() 特别的:字符串转成其他要先用eval() #字符串转为元组,返回:(1, 2, 3) print (tuple(eval("(1,2,3)"))) #字符串转为列表,返回:[1, 2, 3] 阅读全文
posted @ 2017-07-28 09:23
细雨轻风
阅读(440)
评论(0)
推荐(0)

浙公网安备 33010602011771号