This article example describes the Python3 implementation of finding a file from a specified path. Shared for your reference. Specific implementation methods are as follows:
Here given a search path, based on this path request and the requested file name, find the first file that matches the request
import os def search_file(file_name, search_path, pathsep = ): for path in search_path.split(pathsep): candidate = (path, file_name) if (candidate): return (candidate) return None search_path = 'd:\\pm\\pm' find_file = search_file('', search_path) if find_file: print("File '' found at %s" % find_file) else: print("File '' not found")
I hope that what I have described in this article will help you with your Python 3 programming.