I need help learning 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 one line with just one name, and using json_dumps does not generate any output (I did not quite understand how to use the 'json' lib from python, I thought it was for exporting data .)
I also ask how do I output to be in UTF-8 charset? The output, when I print the result in the python compiler, comes with unrecognized characters, so I do not understand why the code is 'set' in utf-8.
I'm waiting for people to help me solve the problem.