企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
##### Number(数字) - 数字(Number)类型 python中数字有四种类型:整数(int长整型)、布尔型、浮点数和复数(1.1 + 2.2j)。 ```python >>> a, b, c, d = 20, 5.5, True, 4+3j >>> print(type(a), type(b), type(c), type(d)) <class 'int'> <class 'float'> <class 'bool'> <class 'complex'> >>>a = 111 >>> isinstance(a, int) # True ``` - isinstance 和 type 的区别在于: type()不会认为子类是一种父类类型。 isinstance()会认为子类是一种父类类型。 ```python >>> class A: ... pass >>> class B(A): ... pass >>> isinstance(A(), A) # True >>> type(A()) == A # True >>> isinstance(B(), A) # True >>> type(B()) == A # False ``` - 数值运算 ```python >>> 2 / 4 # 除法,得到一个浮点数 0.5 >>> 2 // 4 # 除法,得到一个整数 0 >>> 2 ** 5 # 乘方 32 ```