单引号和双引号:
在双引号中的字符串与单引号中的字符串的使用完全相同使用三引号('''或"""):
利用三引号,你可以指示一个多行的字符串。你可以在三引号中自由的使用单引号和双引号。
例如:
'''This is a multi-line string. This is the first line.
This is the second line.
"What's your name?," I asked.
He said "Bond, James Bond."
'''
转义符:
'What\'s you name' (注意要加上\来转义'不然python会不认识')
级联字符串:
如果你把两个字符串按字面意义相邻放着,他们会被Python自动级连。例如,'What\'s' 'your name?'会被自动转为"What's your name?"。
阅读(297) | 评论(0) | 转发(0) |