Reputation: 10153
I have following string
string = """
Hello/nWorld
123
HelloWorld
"""
But when I print it I get
Hello
World
123
HelloWorld
But I want to get
Hello/nWorld
123
HelloWorld
Upvotes: 0
Views: 1293
Reputation: 2945
Add a \
to escape the other \
char:
string = """
Hello\\nWorld
123
HelloWorld
"""
or have a "raw" string:
string = r"""
Hello\nWorld
123
HelloWorld
"""
Upvotes: 2
Reputation:
Your code is doing exactly what you want it to do, at least on Linux:
>>> string = """
... Hello/nWorld
... 123
... HelloWorld
... """
>>> print(string)
Hello/nWorld
123
HelloWorld
Are you perhaps on a system that uses /n
as newline?
Upvotes: 1