len(s)
用来判断对象的长度。

需要说明的是,整型,布尔等是没有长度这一说法的。字符串、字典、列表和元组都有长度。

例子:

>>> len()
Traceback (most recent call last):
File "<stdin>", line , in <module>
TypeError: object of type 'int' has no len()
>>> len('hello') >>> len(True)
Traceback (most recent call last):
File "<stdin>", line , in <module>
TypeError: object of type 'bool' has no len()
>>> len([,,,]) >>> len({'name':'tom','':'',})

Python内置函数之len()的更多相关文章

  1. Python内置函数(44)——len

    英文文档: len(s) Return the length (the number of items) of an object. The argument may be a sequence (s ...

  2. Python内置函数(37)——len

    英文文档: len(s) Return the length (the number of items) of an object. The argument may be a sequence (s ...

  3. python内置函数

    python内置函数 官方文档:点击 在这里我只列举一些常见的内置函数用法 1.abs()[求数字的绝对值] >>> abs(-13) 13 2.all() 判断所有集合元素都为真的 ...

  4. python 内置函数和函数装饰器

    python内置函数 1.数学相关 abs(x) 取x绝对值 divmode(x,y) 取x除以y的商和余数,常用做分页,返回商和余数组成一个元组 pow(x,y[,z]) 取x的y次方 ,等同于x ...

  5. Python 内置函数笔记

    其中有几个方法没怎么用过, 所以没整理到 Python内置函数 abs(a) 返回a的绝对值.该参数可以是整数或浮点数.如果参数是一个复数,则返回其大小 all(a) 如果元组.列表里面的所有元素都非 ...

  6. 【转】python 内置函数总结(大部分)

    [转]python 内置函数总结(大部分) python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为 ...

  7. python内置函数,匿名函数

    一.匿名函数 匿名函数:为了解决那些功能很简单的需求而设计的一句话函数 def calc(n): return n**n print(calc(10)) #换成匿名函数 calc = lambda n ...

  8. python 内置函数总结(大部分)

    python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为我们提供了68个内置函数.它们就是pytho ...

  9. python内置函数大全(分类)

    python内置函数大全 python内建函数 最近一直在看python的document,打算在基础方面重点看一下python的keyword.Build-in Function.Build-in ...

随机推荐

  1. [BZOJ 3571] 画框

    Link: BZOJ 3571 传送门 Solution: 和 BZOJ2395 的建模完全相同,(BZOJ2395 题解传送门) 仅仅是将其中的基础问题由最小生成树改成了二分图最大完美匹配 只要将原 ...

  2. python3 开发面试题(字典和拷贝)5.30

    """ 问:执行完下面的代码后, l,m的内容分别是什么? """ def func(m): for k,v in m.items(): m ...

  3. Linux下使用xargs将多行文本转换成一行并用tr实现逗号隔开

    准备: cat test.txt 示例: cat test.txt | xargs 可以看出得到的字符串为空格隔开的. 再把上面的字符串用逗号隔开,可以使用tr命令进行空格的替换 cat test.t ...

  4. 【SQL Server学习笔记】事务、锁定、阻塞、死锁 sys.sysprocesses

    http://blog.csdn.net/sqlserverdiscovery/article/details/7712068 Column name Data type Description   ...

  5. Telnet环境变量

    转:http://www.cnpaf.net/Class/Telnet/200408/2.html 当前位置: 网站首页>>协议大全>>TELNET协议>> Tel ...

  6. GIS空间参考及坐标转换

    空间参考(Spatial Reference)是 GIS 数据的骨骼框架,能够将我们的数据定位到相应的位置,为地图中的每一点提供准确的坐标. 在同一个地图上显示的地图数据的空间参考必须是一致的,如果两 ...

  7. leetcode练习之No.1------ 两数之和Two Sum

    github地址:git@github.com:ZQCard/leetcode.git 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数. 你可以假设每个输入只对应一种答案,且同样的元素不能 ...

  8. The method Inflate() in android

    Inflate() method can find out a layout defined by xml,as like the findViewById() method,but there ha ...

  9. fedora25安装和docker-ce_清华源

    docker-ce_清华源 https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/fedora/ fedora25 docker-ce版本: htt ...

  10. Java源码阅读LinkedHashMap

    1类签名与注释 public class LinkedHashMap<K,V> extends HashMap<K,V> implements Map<K,V> 哈 ...