def getAppointFilepathls fileList = oslistdirpath try for tmp in fileList pathTmp = ospathjoinpathtmp if True==ospathisdirpathTmp getAppointFilepathTm
The function getAppointFile takes two parameters: path and ls. path is the directory path from where you want to search for files, and ls is a list where the file paths will be appended.
The function uses the os.listdir method to get a list of all files and directories in the specified path. It then iterates through each item in the list.
If the item is a directory, the function recursively calls itself with the directory path as the new path parameter. This allows the function to search for files in subdirectories as well.
If the item is a file and has a file extension of '.PY' (case-insensitive), the file path is appended to the ls list.
If a PermissionError occurs during the process, it is caught and ignored. This is done to handle any permission issues that may arise when trying to access certain files or directories.
At the end of the function, the ls list will contain all the file paths that match the specified criteria
原文地址: https://www.cveoy.top/t/topic/hYVe 著作权归作者所有。请勿转载和采集!