python:find_index

文書の過去の版を表示しています。


文字列検索(find, index)

find('文字列'[, 開始位置[, 終了位置]])
index('文字列'[, 開始位置[, 終了位置]])
a =  'abcdefabcdef'
 
a.find('cg')
-1
a.index('cg')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: substring not found
 
a.find('cd')
2
a.index('cd')
2
 
a.find('cd', 6)
8
a.index('cd', 6)
8
 
a.find('cg', 6)
-1
a.index('cg', 6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: substring not found
  • python/find_index.1564171224.txt.gz
  • 最終更新: 2019/07/27 05:00
  • by ともやん