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
真的