# coding=utf8import os.pathdef main(rootdir): print_path = '\\\n' headers_set = set() for parent,dirnames,filenames in os.walk(rootdir): for filename in filenames: if filename.endswith('.c') or filename.endswith('.cpp'): file_path = os.path.join(parent, filename) print_path += file_path.replace(rootdir, '').replace('\\', '/') + ' \\\n' if filename.endswith('.h'): file_path = parent headers_set.add(file_path.replace(rootdir, '').replace('\\', '/') + ' \\\n') print(print_path) print('header path \n') print("".join(headers_set))if __name__ == '__main__': # 路径 rootdir = 'C:\\software\\FFmpeg\\libavcodec\\' main(rootdir)