该函数是一个类对象

class bool([x])

bool()只能传入一个参数。

bool()用来判断对象是否为True,返回值为True或者False。

下面看看例子:

>>> bool('ok')
True
>>> bool('')
False
>>> bool()
False
>>> bool(12)
True
>>> bool([1,2,''])
True

 

相关文章:

  • 2021-06-08
猜你喜欢
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2021-10-02
相关资源
相似解决方案