1 literal constants, such as 2, ' This is ok ' such a string
>>> print (' a,2,3 ')
a,2,3
2 string
Single quotation mark (')
Use single quotation marks to indicate a string, similar to a strong reference in the shell, with all the spaces and tabs intact.
>>> print (' This is OK ')
This is OK
>>> print ("This is OK")
This is OK
Three quotation marks ("')
Using three quotation marks, you can indicate a multiline string, and you can use single and double quotation marks freely in three quotes.
>>> ' This is am am string. The first line.
... The second line.
... "What ' s your name?" Lasked.
... He said "Bond,jamesbond."
' This is am am string. This was the first line.\nthis is the second line.\n "What\ 's your name?" Lasked.\nhe said "Bond,jamesbond."
>>> ' what \ ' s your name ' #在单引号中实现单引号的使用
"What ' s your name"
or use double quotation marks
>>> "What ' Your Name"
"What ' Your Name"
>>> "This is \" Ok\ "," #双引号中实现双引号的引用
' This is ' OK ', '
Note: The line end is a separate backslash, indicating that the string continues on the next line, such as:
>>> ' This is ok\
..., hello '
' This is Ok,hello '
>>> R ' New line is by \ n '
' New line is by \\n '
This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1925662
A concise tutorial for Python: Basic concepts