How to print backslash with Python?
When I write:
print '\' or
print "\" or
Python doesn't print me the backslash
What should I do to get the expected result?
You need to escape your backslash by preceding it with, yes, another backslash:
\ character is called an escape character, which interprets the character following it differently. For example,
n by itself is simply a letter, but when you precede it with a backslash, it becomes
\n, which is the
As you can probably guess,
\ also needs to be escaped so it doesn't function like an escape character. You have to... escape the escape, essentially.
★ Back to homepage or read more recommendations: