Lara Posted May 31, 2021 Share Posted May 31, 2021 Hi In Escape character, Backslash character (\\) does it work in Python? In the following examples, whether I use \ or \\, the result is the same! print("This will insert one\(backslash).")→This will insert one\(backslash) print("This will insert one\\(backslash).")→This will insert one\(backslash) Link to comment Share on other sites More sharing options...
lakshitha Posted June 12, 2021 Share Posted June 12, 2021 (edited) 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 June 12, 2021 by lakshitha because misunderstood the question Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now