下面的代码可以通过filter函数和自定义的过滤函数从数组中过滤出以字母C开头的元素
# Suppose you have a list of people's first names. You want to reduce the list down to only those people whose first names start with "C".
people = ['Amy', 'Alice', 'Bobby', 'Charlie', 'Connie', 'David']
# You would create a callback function that would look something like this:
def starts_with_c(name):
if name[0] == "C":
return True
return False
# So then, you would run the filter function
starts_with_c_list = filter(starts_with_c, people)
print starts_with_c_list
# prints ['Charlie', 'Connie']
