标签:表示 ica unicode str highlight bsp nic pytho ted
1、行末单独一个反斜杠表示字符串在下一行继续,而不是开始一个新的行。
>>> "This is the first sentence.... This is the second sentence." ‘This is the first sentence.This is the second sentence.‘
2、自然字符串,如何需要某些字符串不需要转义,可以添加前缀r或R。
>>> a = r"Newlines are indicated by \n" >>> print a Newlines are indicated by \n
3、转换为Unicode字符串
>>> line = u"This is a Unicode string" >>> print line This is a Unicode string
4、python把程序中用到的任何东西都称为对象,使用变量和字面意义上的常量
#!/usr/bin/env python i = 5 print i i = i + 1 print i s = ‘‘‘This is a multi-line string. This is the second line.‘‘‘ print s
# python var.py 5 6 This is a multi-line string. This is the second line.
标签:表示 ica unicode str highlight bsp nic pytho ted
原文地址:http://www.cnblogs.com/wangtao1993/p/5999044.html