- 函数名:not,bool()
- 作用:返回布尔值,简单用法见代码,可让代码看起来更简洁一些
- 调用方法:not obj,bool(obj)
- 参数:
obj:Python中的各种数据对象,包括整型,列表,字符串,集合等
官方解释:
class bool([x])
Return a Boolean value, i.e. one of True or False. x is converted using the standard truth testing procedure. If x is false or omitted, this returns False; otherwise it returns True. The bool class is a subclass of int (see Numeric Types — int, float, complex).
It cannot be subclassed further. Its only instances are False and True (see Boolean Values).
Changed in version 3.7: x is now a positional-only parameter.
operator.not_(obj)
operator.not(obj)
Return the outcome of not obj. (Note that there is no
not() method for object instances; only the interpreter c