Python單引號雙引號三引號的區別

一、單引號與雙引號用於單行,功能上是等價的。
spa

    二者配合使用,減小使用轉義符。three

  例如: 等價的it

   print "I LOVE 'CHINA'"ant

   print 'I LOVE \'CHINA\''ab


2、三引號用於多行,內部不使用轉移符,原樣輸出。

  print ''' I LOVE 'CHINA'   '''(等價)

示例:

days="Mon Tue Wed Thu Fri Sat Sun"
months="Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"

print "Here are the days:",days
print "Here are the months:",months

print """

There's something going on here.with the three double-quotes.We'll be able to type as much as we like Even 4 lines if we want or 5,or 6"""

相關文章
相關標籤/搜索