I have a list with file.txt paths
With the read () function, I can save the entire contents of the file into a list where each word is stored in a list position. But since I intend to read 3 files at once and save the contents of each file in a list, I thought about saving those 3 generated lists of their 3 files in a list of lists. It would be something like this so I'm trying to sketch it:
lista_nome_base_docs = ['a.txt', 'b.txt', 'c.txt']
tamanho_lista_base_docs = len(lista_nome_base_docs)
print (tamanho_lista_base_docs)
lista_string_arquivos = [[]]
for i in range(3):
with open(lista_nome_base_docs[i],"r") as arquivo:
lista_string_arquivos.append(arquivo.read())
print (lista_string_arquivos)
I'm trying to save the contents of each file in a list of lists ... could anyone give me an idea how to solve this?
At the end when I send printers, it's coming out totally strange is list of lists:
[[], '€\x03]q\x00]q\x01a.', '€\x03]q\x00]q\x01a.', '€\x03]q\x00]q\x01a.']