1
I did this snippet of code to read through a loop the contents of the list files.
lista_nome_base_docs = ['a.txt', 'b.txt', 'c.txt']
tamanho = len(lista_nome_base_docs)
print (tamanho)
lista_geral_arquivos = []
for i in range(tamanho):
with open(lista_nome_base_docs[i],"r") as arquivo:
conteudo = [line.strip() for line in arquivo if line.strip() != "" and line.strip() != "." and line.strip() != "\n" and line.strip() != "!" and line.strip() != "?" and line.strip() != ":" and line.strip() != "," and line.strip() != ""]
lista_geral_arquivos.append(conteudo)
print (lista_geral_arquivos)
but my list list gets this content:
[['€\x03]q\x00]q\x01a.'], ['€\x03]q\x00]q\x01a.'], ['€\x03]q\x00]q\x01a.']]
does anyone know how the words appear instead of these strange characters? I have tried the .read()
and .readlines()
and they’re not putting each word in a list position, but this bunch of jumbled characters...
What is the content of these files?
– Woss
@Andersoncarloswoss are just phrases with , - : - . and ? in the middle of words, a very simple text
– William Henrique
for i in range(tamanho):
 with open(lista_nome_base_docs[i],"r") as arquivo:
 conteudo = arquivo.readlines()
 lista_geral_arquivos.append(conteudo)

print (lista_geral_arquivos)
doing so tbm reads a lot of strange thing @Andersoncarloswoss– William Henrique
@Andersoncarloswoss got here.... after you asked me about the contents of the files I went to check, and I do not know why, the sentence was exchanged for characters in Japanese hahaha, I switched the content and it worked
– William Henrique