采用os模块儿:
import os def get_filelist(dir): for home, dirs, files in os.walk(dir): print("#######dir list#######") for dir in dirs: print(dir) print("#######dir list#######") print("#######file list#######") for filename in files: print(filename) fullname = os.path.join(home, filename) print(fullname) print("#######file list#######") if __name__ == "__main__": get_filelist('C:\Python3\Scripts')