movie_people = ['sb_alex', 'sb_wupeiqi', 'hello']def filter_test(array): ret = [] for p in array: if not p.startswith('sb'): ret.append(p) return retres = filter_test(movie_people)print(res)def sb_shown(n) return n.endswith('sb')def filter_test(,func, array): ret = [] for p in array: if not func(p) ret.append(p) return retres = filter_test(sb_shown, movie_people)print(res)#终极版本def filter_test(,func, array): ret = [] for p in array: if not func(p) ret.append(p) return retres = filter_test(lambda:n: not n.endswith('sb'), movie_people)print(res)#filter函数res = filter(lambda n:not n.endswith('sb'), movie_people)print(list(res))