打印当前目录所有文件名 import fnmatch, os
def allFiles(root, patterns = '*', single_level = False, yield_folders = False):
patterns = patterns.split(';')
for path, subdirs, files in os.walk(root):
if yield_folders:
#add subdirs to the tail of files
files.extend(subdirs)
files.sort()
for name in files:
for pattern in patterns:
if fnmatch.fnmatch(name, pattern):
yield os.path.join(path, name)
break
#only deal one level of the dir
if single_level:
break
for name in allFiles('D:\E\semantic\zzzz', single_level = True):
print(name)