def files_list_to_texts(files_list, glob="**/[!.]*"): texts = [] for i in files_list: if i.name.split('.')[-1] in ['txt']: with open(i.name, encoding='utf-8') as f: text = f.readlines() text = [i for i in text] texts.append(''.join(text)) return texts