Use line break with the appropriate escape for this, just add '\n'
to the end of the string. In the example below I read the strings from a list and add the line break when I write to the file:
arquivo = open("arquivo.txt", "a", newline="")
persons = ['Jose antonio de oliveira; [email protected]',
'Ana Fake da Silva; [email protected]']
for p in persons:
arquivo.write(p+'\n')
arquivo.close()
Displaying the contents of the file with the command cat
(Linux):
cat arquivo.txt
Jose antonio de oliveira; [email protected]
Ana Fake da Silva; [email protected]
Edited
After reading the comments more closely, I thought I should complement the answer.
Reading the file:
With readlines()
:
lines = open('arquivo.txt','r').readlines()
print (lines)
['Jose antonio de oliveira; [email protected]\n', 'Ana Fake da Silva; [email protected]\n']
With splitlines()
:
lines = open('arquivo.txt','r').read().splitlines()
print (lines)
['Jose antonio de oliveira; [email protected]', 'Ana Fake da Silva; [email protected]']
See that splitlines()
, "automagically" removes the escape for line break.