Skip to content

逻辑

Python 的 bool 类型有两个常量:True 和 False 。

逻辑运算符有:and 、or 和 not 。

比较运算符有

  • ==
  • !=
  • >
  • <
  • >=
  • <=
  • is
  • is not

相关内置函数有 all any 。

all([True, False])

any([True, False])
False

True

检查数据类型

isinstance(1, int)
isinstance(1.5, float)
isinstance(1+2j, complex)

isinstance('1', str)

isinstance(True, bool)
True
True
True

True
True

联系 math@baima.site