python - 基础类型 - bool

发布时间:2019-08-23 07:58:37编辑:auto阅读(1510)

    bool:python中布尔值使用常量True和False来表示

     

    注:

     

    1.在数值上下文环境中,True被当作1,False被当作0,例如 True+3=>4

     

    2.其他类型值转换bool值时除了''、""、''''''、""""""、0、()、[]、{}、None、0.0、0L、0.0+0.0j、False为False,其他都为True 例如 bool(-2)=>True

关键字