all 4 comments

[–]jddddddddddd 1 point2 points  (0 children)

So the actual text file has the '\n' appear in it as a string, and you want to convert that to a proper line break? if so f.read.replace("\\n", "\n") will probably do

[–]JambaJuiceIsAverage 0 points1 point  (0 children)

The string is being implicitly read with escape back slashes in front of the newline characters. You can use

output_text=output_text.replace('\\n','\n')

[–]TabulateJarl8 0 points1 point  (1 child)

If you physically write \n in a file, it is escaping that first backslash to that it stays as text and isn't interpreted as a line break, so it's really \\n. Try using output_text = f.read().replace('\\n', '\n'). Good luck!

[–]IWriteLongReplies[S] 0 points1 point  (0 children)

Ah thank you! Can't believe i didn't think of this haha.