Python基础笔记 之基础
- print会依次打印每个字符串,遇到逗号“,”会输出一个空格
>>> print 'The quick brown fox', 'jumps over', 'the lazy dog'
The quick brown fox jumps over the lazy dog
- 可以用’’’…’’'表示多行字符串:
'''Python is created by "Guido".
It is free and easy to learn.
Let's start learn Python in imooc!'''
- 在字符串前面加个前缀 r ,表示这是一个 raw 字符串,里面的字符就不转义,但是r’…'表示法不能表示多行字符串,也不能表示包含’和 "的字符串
r'\n\n\n\n\\'
- Python在后来添加了对Unicode的支持,以Unicode表示的字符串用u’…'表示,这样解决了中文的问题:
>>>print u'中文太棒啦!'
中文太棒啦!
若 代码编辑第一行的注释#--coding:utf-8 --,表明以下Python代码使用utf-8编码,不需要再使用u’…’