一、 翻转序列
>>>s="abcdef"
>>>s[::-1]
"fedcba"
二、各一个取一个
>>>s[::2]
"ace"
三、None索引值
>>>s="abcde"
>>>for i in [None] +range(-1,-len(s),-1):
``` print s[:i]
```
abcde
abcd
abc
ab
a
四、序列常函数
len(s) max(s) min(s) reversed(s) sorted(s) sum(s)
五、字符串模板
>>>from string import Template
>>>s = Template('There are ${howmany} ${lang} quotation Sysmbols')
>>>print s.safe_substitute(lang='python',howmany=3)
>>>print s.substitute(lang='python',howmany=3)
六、 寻找原始的\n字符二不是换行
>>>import re
>>>m = re.search(r'\\[rtfvn]',r'hello world!\n')
>>>if m is not None:m.group()
```'
'\\n'
七、字符串内嵌函数
cmp() 返回0 表示相等
len() max() min()
enumerate() 例子:
>>>s = "foobar"