python字符串操作
参考:
http://www.runoob.com/python/python-strings.html
http://blog.csdn.net/ataraxia2010/article/details/6907907/
index
返回查找字符串的索引位置,如果没找到抛出异常
a='mark is cool'
print(a.index('xss'))
# ValueError: substring not found
find
返回查找字符串的索引位置,如果没找到返回-1
a='mark is cool'
print(a.find('xss'))
# -1
获取子串
直接使用字符串的索引访问的切片功能
mystr= 'hello mark'
print(mystr[6::]) # mark
print(mystr[6:8]) # ma
print(mystr[:len(mystr)-2]) # hello ma