标签:
第一种:
1 [i for i in range(10) if i % 2 == 0]
结果:[0, 2, 4, 6, 8]
第二种:
seq = [‘one‘, ‘two‘, ‘three‘] for i, element in enumerate(seq): seq[i] = "%d: %s" % (i, seq[i]) print seq
结果:[‘0: one‘, ‘1: two‘, ‘2: three‘]
标签:
原文地址:http://www.cnblogs.com/selfimprovement/p/5942722.html