Python tuple len()返回元组中的元素数。
len(tuple)
tuple - 这是要计算的元素数的元组。
此方法返回元组中的元素数。
链接:https://www.learnfk.comhttps://www.learnfk.com/python/tuple-len.html
来源:LearnFk无涯教程网
以下示例显示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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕