Is there a way to litterally print an escape sequence such as \n? For example:
print "Hello\nGoodbye"
The output of this would be:
Hello
Goodbye
Is there a way to get it to literally print out this?
Hello\nGoodbye
Is there a way to litterally print an escape sequence such as \n? For example:
print "Hello\nGoodbye"
The output of this would be:
Hello
Goodbye
Is there a way to get it to literally print out this?
Hello\nGoodbye
You can place the string in repr
:
>>> mystr = "Hello\nGoodbye"
>>> print mystr
Hello
Goodbye
>>> print repr(mystr)
'Hello\nGoodbye'
>>> # Remove apostrophes
>>> print repr(mystr)[1:-1]
Hello\nGoodbye
>>>