import os def read_flies(): path=input("")+'/' files =os.listdir(path) files_name = [] for file in files: if file.split('.')[-1]=='txt': files_name.append(file) return path,files_name def make_file(path,files): content='' for file_name in files: with open(file_name, 'r',encoding='utf-8') as file: content =content + file.read() file.close() with open(path+ 'a', encoding='utf-8') as file: file.write(content) content='' file.close() if __name__ == '__main__': path, files = read_files() mixed_file(path,files)
合并文件的方式
最新推荐文章于 2023-08-04 10:46:34 发布