标签:style blog color ar for strong sp div on
自己的几个list常用用法。
mylist = [i for i in range(10)] mylist.pop(-1) mylist.append(9) mylist_1 = [i for i in range(10,20)] mylist_2 = zip(mylist, mylist_1)
mylist.extend(mylist_1)
不常用的extend(), 里面的对象是list.
filter, map, reduce对于可迭代对象的操作。
>>> a = [1,2,3] >>> b = [4,5,6] >>> c = [4,5,6,7,8] >>> zipped = zip(a,b) [(1, 4), (2, 5), (3, 6)] >>> zip(a,c) [(1, 4), (2, 5), (3, 6)] >>> zip(*zipped) [(1, 2, 3), (4, 5, 6)]
Exercise 34: Accessing Elements Of Lists
标签:style blog color ar for strong sp div on
原文地址:http://www.cnblogs.com/hluo/p/4049873.html