'' '
Needs: Get there .py files in the specified directory and its subdirectories
' ''
Import os
L = []
DEF getPyFile (path, L):
fileList = os.listdir (path) # obtain files and folders
filename in the fileList for:
filepath = the os.path.join (path, filename) # splicing path
IF os.path.isdir (filepath):
getPyFile (filepath, L)
the else:
# filename = os.path.splitext (filepath) # get file extension
# Print (filename)
IF filename [-3:] == ".py":
l.append (filepath)
IF __name__ == "__main__":
the p-the iNPUT = ( "Please enter the path:")
getPyFile (the p-, L)
for FileItem in L:
Print (FileItem)
There .py file to obtain the specified directory and its subdirectories under
Guess you like
Origin www.cnblogs.com/nishoufeng/p/12063872.html
Ranking