3 回答
TA贡献2041条经验 获得超4个赞
您可以通过以下三种方式之一完成此操作:
1)一起使用单引号和双引号:
>>> print '"A word that needs quotation marks"'
"A word that needs quotation marks"
2)转义字符串中的双引号:
>>> print "\"A word that needs quotation marks\""
"A word that needs quotation marks"
3)使用三引号字符串:
>>> print """ "A word that needs quotation marks" """
"A word that needs quotation marks"
TA贡献1963条经验 获得超6个赞
你需要逃脱它:
>>> print "The boy said \"Hello!\" to the girl"
The boy said "Hello!" to the girl
>>> print 'Her name\'s Jenny.'
Her name's Jenny.
有关字符串文字,请参阅python页面。
TA贡献1811条经验 获得超4个赞
Python接受“和”作为引号,所以你可以这样做:
>>> print '"A word that needs quotation marks"'
"A word that needs quotation marks"
或者,只是逃避内心的
>>> print "\"A word that needs quotation marks\""
"A word that needs quotation marks"
添加回答
举报