Python 元组长度

元组长度

要确定一个元组有多少项,请使用 len() 方法:

实例

打印元组中的项数:

thistuple = ("apple", "banana", "cherry")
print(len(thistuple))

亲自试一试