str.index(sub[,start[,end]])
此格式中各参数的含义分别是: >>> str = "www.xnip.cn"
>>> str.index('.')
3
>>> str = "www.xnip.cn"
>>> str.index('z')
Traceback (most recent call last):
File "<pyshell#49>", line 1, in <module>
str.index('z')
ValueError: substring not found
>>> str = "www.xnip.cn"
>>> str.rindex('.')
8