arq = open("/Users/DIGITAL/Desktop/Python/novo.txt", "w")
arq.write(palavras)
arq.close()
I'm using this code, but it only accepts string.
arq = open("/Users/DIGITAL/Desktop/Python/novo.txt", "w")
arq.write(palavras)
arq.close()
I'm using this code, but it only accepts string.
You can do something like this:
with open('test.txt', 'r') as arquivo_existente, open('novo_arquivo.txt',
'w') as novo_arquivo:
for linha in arquivo_existente.readlines():
novo_arquivo.write(linha)
When executing the above code, the content of arquivo_existente.txt
will be copied to the file novo_arquivo.txt