Python标准库:内置函数len(s)
Python标准库:内置函数len(s)
本函数是返回对象s的长度,所谓的长度是指容器类的数据项个数,比如字符串、元组、列表、字典等。
例子:
#len() s = '123456789' soft = '软件' print(s, ': ', len(s)) print(soft, ': ', len(soft)) l = [2,3,4,5] print(l, ': ', len(l)) d = {2 : 'two', 3 : 'three' } print(d, ': ', len(d))
结果输出如下:
123456789 : 9
软件 : 2
[2, 3, 4, 5] : 4
{2: 'two', 3: 'three'} : 2
蔡军生 QQ:9073204 深圳
相关内容
- Python标准库:内置函数hasattr(object, name)
- Python标准库:内置函数format(value[, format_spec])
- Python标准库:内置函数format(value[, format_spec])
- python lambda 函数 学习
- python获得线程调用函数的返回值
- python获得线程调用函数的返回值
- Python标准库:内置函数exec(object[, globals[, locals]])
- Python标准库:内置函数eval(expression, globals=None, locals=N
- Python标准库:内置函数dict(iterable, **kwarg)
- Python标准库:内置函数classmethod(function)
评论关闭