Skip to content Skip to sidebar Skip to footer

Can't Escape Escape Characters In String

In an attempt to answer this question, I managed to get the string to print the escape characters by escaping the backslash. When I try to generalize it to escape all escaped chara

Solution 1:

Define your string as raw using r'text', like in the code below:

a = r"word\nanother word\n\tthird word"
print(a)
word\nanother word\n\tthird word

b = "word\nanother word\n\tthird word"
print(b)
word
another word
        third word

Post a Comment for "Can't Escape Escape Characters In String"