python简明手册学习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 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.
以上是关于python简明手册学习的主要内容,如果未能解决你的问题,请参考以下文章