Reputation: 1742
As you know that python support both '
and "
for string like
a = 'str'
b = "str"
If I want to represent the symbol "
, I can use:
a = '"'
However, I don't want to use '
, is there any way? In java, which does not allow '
for string representing, I can use:
a = "\""
but this escape won't work in python
print("\"") # >>> \"
Thanks
Upvotes: 0
Views: 161
Reputation: 54213
If you cannot use '
and must use raw strings, then there is no way to express a single double quotation mark "
as a string.
There are two methods of including a string delimiter ('
or "
) in a string:
'"'
or "'"
"\""
or '\''
Your constraints remove both of those possibilities.
Upvotes: 0
Reputation: 29
you can perhaps use a triple quoted string
print("""I wasn't, I shan't. "This is a quote".""")
your output should be
I wasn't, I shan't. "This is a quote".
Upvotes: 1