您可以通过以下三种方式之一完成此操作: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"
你需要逃脱它:>>> 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页面。
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"