菜鸟教程 -- 学的不仅是技术,更是梦想!

Python 基础教程
(追記) (追記ここまで)

Python Tuple(元组) len()方法

Python 元组Python 元组


描述

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 元组Python 元组

AI 思考中...

点我分享笔记

  • 昵称 (必填)
  • 邮箱 (必填)
  • 引用地址

AltStyle によって変換されたページ (->オリジナル) /