0
I need help to learn how to export data from an object. At first I need to export in type "txt" and/or "json", but I could not succeed in either.
The code:
#coding = utf-8
import json
.
.
.
def arquivo(lista_nomes):
print(json.dumps(lista_nomes))
def txt(lista_nomes):
arq = open('listaNomes.txt', 'w')
arq.write(for i in lista_nomes:)
arq.close()
for lista_nome in lista:
txt(lista_nomes)
arquivo(lista_nomes)
.
.
.
Trying to export with the "txt" function, I only get a line with only one name, and using json_dumps I don’t have any output(I didn’t quite understand how to use the python lib 'json', I thought it was to export data.)
I also ask how should I make out be in UTF-8 charset? The output, when printing the output in the python compiler, comes with unrecognized characters, so I don’t understand why since the code is 'set' in utf-8.
I’m standing by, guys, to help me solve the problem.
How is the structure of your . txt? One name per line? And how and what order are the functions being called in your main file..
– Marlysson
@Marlysson, yes the text comes a ["name", "lymph formation"]. As far as the functions I believe do not matter, however their call is the same as posted above.
– vic.py