Alex Rivera | Logout

How to include a double-quote and/or single-quote character in a raw Python string literal?

Asked 2011-01-07T21:27:30.743
127

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?

Related

Edit
Report

1 Answer

5

Nevermind, the answer is raw triple-quoted strings:

r"""what"ever"""
answered 2011-01-07T21:33:08.307

Your Answer