I want to save the following string into a file using Python. The string includes \n which I don't want to be converted into a new line. Here is my code:
text = 'hello "\n" world'
file = open("file.js", "w")
file.write(text)
file.close()
When I open file.js
I get the following output (which is expected):
hello "
" world
Is there any way to save the file without the newlines being forced to be be converted? My desired output to the file would be:
hello "\n" world