首页 > 编程知识 正文

python中int函数的用法,python布尔值

时间:2023-05-04 07:03:22 阅读:10906 作者:4740

OOL([x] ) ) )。

英语说明: Convert a value to a Boolean,usingthestandardtruthtestingprocedure.ifxisfalseoromitted,this returns False; otherwiseitreturnstrue.boolisalsoaclass,whichisasubclassofint.classboolcannotbesubclassedfurther.itsonlyinstancesalyincesaresarefarefafafareface

新版本2.2.1。

变更版本2.3: ifnoargumentisgiven,this function returns False。

中文说明:将x转换为布尔型,如果x为缺省值,则返回False。 bool也是int的子类。

参数x :任何对象或默认值; 注意:这里使用的是[x]。 这表明可以有也可以没有x参数。 如果没有给出任何参数,则返回False。

版本: python 2.2.1中引入的新函数返回False,除非传递python2.3或更高版本的参数。

注意:此函数在python3中也可以正常使用

示例: bool(0()0) ) )。

假的

bool(ABC ) )。

真的

bool (' )。

假的

bool([] ) ) )。

假的

BOL () ) )

假的

issubclass(bool,int ) #bool是subclass int

真的

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。