len() 函数

  • 定义:返回对象长度
  • 实例:
    • str = "runoob" print( len(str) ) # 字符串长度,结果输出 6 l = [1,2,3,4,5] print( len(l) ) # 列表元素个数,结果输出 5