import os
import os.path
import sys
import glob
def getalltxtfilename2(path):
txtfilenames=[]
for dirpath,dirnames,filenames in os.walk(path):
filenames=filter(lambda filename:filename[-4:]=='.mp3',filenames)
filenames=map(lambda filename:os.path.join(dirpath,filename),filenames)
txtfilenames.extend(filenames)
#print filenames
return txtfilenames
if __name__ == "__main__" :
try :
filenames=getalltxtfilename2("E:\cocos2d-x-2.2.2\projects\Constellation\Resources\Sound")
for filename in filenames:
print filename
except :
print "execute list_file_dir fun error"
转载于:https://my.oschina.net/wysrc/blog/201904