Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

When I write:

print '\' or print "\" or print "'\'"

Python doesn't print me the backslash \ symbol.

What should I do to get the expected result?

1 Answer

0 votes
by (106k points)

You can declare a string as raw (with and r in front of it) and it will print all its characters as-is:

>>> s = r'\abc\def' 

>>> print s 

'\abc\def'

This is useful for regular expressions.

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
asked Jan 24, 2021 in Linux by blackindya (18.4k points)
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

Browse Categories

...