+ 1
I am still confused with (\", \') backslash escape characters in python. What is the use of these characters in python?
I also searched many queries related to this topic but still failed to understand.
8 Antworten
+ 4
So, you need to tell python that you don't want to close the string at 'don', you need to escape it, by putting a backslash. Then python knows that it doesn't have to close the string there:
'Don\'t'
+ 4
But how would python know what you want? 'don' looks like a string too.
+ 4
Welcome :)
+ 3
print("He said, 'These are quotation marks in python("") '. ")
In this, the string becomes:
He said, 'These are quotation marks in python(
Because the quotation ends the line. In these cases, escape characters are used:
print("He said, 'These are quotation marks in python(\"\") '. ")
Output:
He said, 'These are quotation marks in python("") '.
+ 3
a = 'Don't!'
In this, what do you expect the value of a?
Don't
or
Don
?
If you forget the part t!', doesn't 'don' seem like a complete string?
+ 1
Thanks ! But sorry your output makes me more confused can you elaborate in easy way if you don't mind?
+ 1
Don't!
+ 1
Arnesh thanks ! You are savior.