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 use raw strings (see here). Just add an r before the string:
>>> print r"hello\nworld" hello\nworld 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 >>>