python字符串查找函數

字符串查找:指定字符串出現的索引位置 find 語法:str.find(target, [start,end) ) 解釋:在字符串中查找指定字符串首次出現的index,找不到時返回-1 index 語法:str.index(target, [start,end) ) 解釋:在字符串裏查找子串第一次出現的位置,找不到子串會拋出異常 ss = 'wangwei' print ss.find('w',1
相關文章
相關標籤/搜索