<p style=
"line-height: 1.75em;"
><span style=
"font-family: 微软雅黑, "Microsoft YaHei";"
>>>>
'"double quote"'
#单引号中,使用双引号,直接将双引号输出
'"double quote"'
>>> a =
'"double quote"'
>>> print(a)
"double quote"
>>>
>>>
"'single quote'"
#双引号中,使用单引号,将单引号输出
"'single quote'"
>>> a =
"'single quote'"
>>> print(a)
'single quote'
>>>
>>>
""
double
""
#双引号中直接输出双引号报错
SyntaxError: invalid syntax
>>>
"\"double\""
#双引号中直接输出双引号报错,但是将其中的双引号通过反斜线进行转义就可以了
'"double"'
>>> a =
"\"double\""
>>> print(a)
"double"
>>>
>>>
''
single
''
#单引号中输出单引号字符报错,加上转义字符就可以了。
SyntaxError: invalid syntax
>>>
'\'single\''
"'single'"
>>> a =
'\'single\''
>>> print(a)
'single'
>>>
'"My python'
, lession
' #单引号中输出双引号可以,如有单引号,必须进行转义
SyntaxError: EOL while scanning string literal
>>> '
"My python\
', lession'
'"My python\', lession'
>>> a =
'"My python\', lession'
>>> print(a)
"My python', lession<br></span></p>