Issue
Consider:
>>> r"what"ever"
SyntaxError: invalid syntax
>>> r"what\"ever"
'what\\"ever'
So how do we get the quote, but not the slash?
And please don't suggest r'what"ever'
, because then the question just becomes how do we include both types of quotes?
Solution
If you want to use double quotes in strings but not single quotes, you can just use single quotes as the delimiter instead:
r'what"ever'
If you need both kinds of quotes in your string, use a triple-quoted string:
r"""what"ev'er"""
If you want to include both kinds of triple-quoted strings in your string (an extremely unlikely case), you can't do it, and you'll have to use non-raw strings with escapes.
Answered By - Adam Rosenfield Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.