Python 列表长度

列表长度

要确定列表中有多少项,请使用 len() 函数:

实例

打印列表中的项数:

thislist = ["apple", "banana", "cherry"]
print(len(thislist))

亲自试一试