标签:lambda reserve list list comprehension string of slice codecademy python
dictionary:
n.items() n.keys() n.values()
三种都是无序的
generate a list according to some logic
evens_to_50 = [i for i in range(51) if i % 2 == 0] even_squares = [x ** 2 for x in range(1,12) if x % 2 == 0]
list负数:reserve the list
letters = [‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘] print letters[::-1] #[‘E‘, ‘D‘, ‘C‘, ‘B‘, ‘A‘]
lambda用法
my_list = range(16) print filter(lambda x: x % 3 == 0, my_list)
slice
str = "ABCDEFGHIJ" start, end, stride = 1, 6, 2 str[start:end:stride]
lambda,reserve list, list comprehension, string of slice
标签:lambda reserve list list comprehension string of slice codecademy python
原文地址:http://jackzones.blog.51cto.com/5001676/1725774