Jump to content

Question about escape characters Hi


Recommended Posts


In Escape character, Backslash character (\\) does it work in Python?

In the following examples, whether I use \ or \\, the result is the same!

  1. print("This will insert one\(backslash).")→This will insert one\(backslash)
  2. print("This will insert one\\(backslash).")→This will insert one\(backslash)
Link to comment
Share on other sites

  • 2 weeks later...

Hi Lara,

If you want to print illegal something in Python, you should use escape character.

>>> print("I am using \" illegal \" something.")
I am using " illegal " something.

else if you want to print two backslashes (\\) in string, you must use r before string.

>>> print(r"This will insert two \\ (backslashes)")
This will insert two \\ (backslashes)


Edited by lakshitha
because misunderstood the question
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...