Python 3 教程教程
Python3 len()方法
Python3 len()方法
Python3 len()方法
Python3 字符串描述
Python len() 方法返回对象(字符、列表、元组等)长度或项目个数。
语法
len()方法语法:
len( s )
参数
- s -- 对象。
返回值
返回对象长度。
实例
以下实例展示了 len() 的使用方法:
>>>str = "verydoc"
>>> len(str) # 字符串长度
6
>>> l = [1,2,3,4,5]
>>> len(l) # 列表元素个数
5
Python3 字符串
Python3 len()方法 |
---|
Python 3 教程
Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下兼容。