Python Tuple(タプル) len()メソッド
説明
Python タプルの len() 関数は、タプルの要素数を計算します。
構文
len() メソッドの構文:
len(tuple)
パラメータ
- tuple -- 計算対象のタプル。
戻り値
関数はタプルの要素数を返します。
実例
以下の実例は len() 関数の使用方法を示しています:
#!/usr/bin/python tuple1, tuple2 = (123, 'xyz', 'zara'), (456, 'abc') print "First tuple length : ", len(tuple1); print "Second tuple length : ", len(tuple2);
上記の実例の出力結果は次のとおりです:
First tuple length : 3 Second tuple length : 2その他の拡張
Python タプル