mv = ['sb_alex','wupeiq_sb','liuhaiquan','sb_yuanhao']
def pd(n):
return n.startswith('sb')
def jj(func,ary):
d = []
for i in mv:
if func(i):
d.append(i)
return d
a = jj(pd,mv)
print(a)
终极版本
filter函数
mv = ['sb_alex','wupeiq_sb','liuhaiquan','sb_yuanhao']
a = filter(lambda n:n.startswith('sb'),mv)
print(a)