python如何查看元组元素个数
可使用Python内置的len()函数来查看元组的元素个数。
具体的方法以下:
my_tuple = (1, 2, 3, 4, 5)
length = len(my_tuple)
print("元组的元素个数为:", length)
完全的代码以下:
my_tuple = (1, 2, 3, 4, 5)
length = len(my_tuple)
print("元组的元素个数为:", length)
运行结果为:
元组的元素个数为: 5
TOP