組み込み型 (Built-in Types)

数値型 (Numeric Types)

数値型 - 組み込み型 — Python 3.x ドキュメント

ブーリアン型 (Boolean Type)

bool ブーリアン型 - 組み込み型 — Python 3.x ドキュメント

イテレータ型 (Iterator Types)

 

シーケンス型 (Sequence Types)

シーケンス型 - 組み込み型 — Python 3.x ドキュメント
演算 結果
x in s  
x not in s  
   
s[i] sの、i番目の要素 (0を起点)
s[i:j] sの、iからjまでのスライス
s[i:j:k] sの、iからjまでの、k毎のスライス
   
s.count(x) sの中でxが出現する総数
共通のシーケンス演算 - 組み込み型 — Python 3.x ドキュメント

テキストシーケンス型 (Text Sequence Type)

メソッド 機能
str.find(sub[, start[, end]]) s[start:end]の範囲で、部分文字列subが含まれている最小のインデックス。位置に無関心ならば、in演算子で調べる
str.startswith(prefix[, start[, end]]) prefixで始まるならTrue
str.endswith(suffix[, start[, end]]) suffixで終わるならTrue
   
文字列メソッド - 組み込み型 — Python 3.x ドキュメント

find()

>>> "abcabc".find("bc")
1
>>> "abcabc".find("bc",2)
4
>>> "abcabc".find("BC")
-1

join()

>>> ",".join(["a","b"])
'a,b'

[解決!Python]リスト(配列)の要素を文字列のjoinメソッドで結合するには:解決!Python - @IT かわさきしんじ (2023/10/04)

抽出

文字列は、スライスで抽出できます。[解決!Python]文字列から特定の文字列以降や特定の文字列の前などを抽出するには(str.find/str.split/str.partitionメソッド、正規表現):解決!Python - @IT かわさきしんじ (2023/10/04)

>>> "abcde"[1:3]
'bc'
>>> "abcde"[2:]
'cde'
>>> "abcde"[:2]
'ab'