首页 > 代码库 > python简明手册学习

python简明手册学习

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 aNewlines are indicated by \n

 

3、转换为Unicode字符串

>>> line = u"This is a Unicode string">>> print lineThis is a Unicode string

 

4、python把程序中用到的任何东西都称为对象,使用变量和字面意义上的常量

#!/usr/bin/env pythoni = 5print ii = i + 1print is = ‘‘‘This is a multi-line string.This is the second line.‘‘‘print s
# python var.py56This is a multi-line string.This is the second line.

  

  

python简明手册学习