質問:
string.contains
とか string.indexof
みたいなメソッドをPythonで探してるんだけど。やりたい事は:
|
By Blankman | 質問日時: Aug 9 ‘10 at 2:52
回答1:
in
演算子を使うといいよ:
|
By Michael Mrozek | 回答日時: Aug 9 ‘10 at 2:56
回答2:
部分文字列検索の場合は string.find("substring")
を使うことができるよ。
でもfind
、index
、in
を使う時はちょっと気をつけて。どうしてかって言うと、それらは部分文字列検索だから。言い換えれば、:
|
これはFound 'is' in the string.
を出力するはず。同様に if "is" in s:
はTrue
と評価されるはず。これは君が望むものかどうかわからないけど。
By eldarerathis | 回答日時: Aug 9 ‘10 at 2:55
Source: Does Python have a string ‘contains’ substring method?