Answer the question
In order to leave comments, you need to log in
How to save a line to a file with line breaks?
I have a line
when I do it ,
it is displayed
when I try to write to a filemystr="here\n is\n my\n string\n"
print(mystr)
here\n is\n my\n string\n
print(mystr, file=(open('myfile.txt', 'w', newline='\n')), sep='\\n')
then the file is also simple, here\n is\n my\n string\n
here
is
my
string
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question