#!/usr/bin/python
def endWith(s,*endstring_1): #*代表允许传输多个参数,名称统一为endstring为元祖,**为字典
array = map(s.endswith,endstring_1) #map(调用的函数名称,给这个函数传的参数)
if True in array:
return True
else:
return False
if __name__ == '__main__':
import os
s = os.listdir('/home/yanchao/')
f_file = []
for i in s:
if endWith(i,'.txt','.py'):
print i,
转载于:https://blog.51cto.com/4249964/1540411