python2.7 get the file name of a file


file_name DEF (file_dir):
"" "
Get pdf file folder following - a first loop for
obtaining obtained pdf file contains" -Y "document - a second for loop
: param file_dir:
: return:
" ""
file_name = []

for Files in the os.listdir (Unicode (file_dir, 'UTF-. 8')):

IF os.path.splitext (Files) [. 1] == 'PDF.':

file_name.append (Files)

files in file_name for:
IF "-Y" in files:
Print files



There are two cycles to obtain the file name with a .pdf under a folder if it is to print all file names, you remove .pdf


second for loop is the resulting file pdf file, taking with "-Y" of

everyone try it

Guess you like

Origin www.cnblogs.com/testling/p/12093306.html