python交互解释器
linux shell
有符号整型,二进制以0b为前缀,八进制以0o为前缀,十六进制以0x,0X为前缀int 例子如:0b01,0o12,0x80,-0X92十进制的例子:84,-237,-680,Python 3.4.3 (default, Nov 28 2017, 16:41:13) [GCC 4.8.4] on linuxType 'help', 'copyright', 'credits' or 'license' for more information.>>> i = 0b01>>> i1>>> type(i)
长整型,仅受限于用户计算机的虚拟内存总数,类似于java中的BigInteger类型long 例如:29979062458,-841401,0xDECADEDEADBEEFBADFEEDDEA长整型已与整型整合为一体,python中会自将超过长度的int转为长整型。Python 3.4.3 (default, Nov 28 2017, 16:41:13) [GCC 4.8.4] on linuxType 'help', 'copyright', 'credits' or 'license' for more information.>>> l = 1>>> l1>>> id(l)10088288>>> type(l)
布尔型是特殊的整型,尽管布尔型常由True和False表示,如果将布尔值放到一个数值上下文环境中,True会被当成整型值1,False会被当成整型值0Python 3.4.3 (default, Nov 28 2017, 16:41:13) [GCC 4.8.4] on linuxType 'help', 'copyright', 'credits' or 'license' for more information.>>> b = True>>> bTrue>>> type(b)
浮点数float例子如:3.1415926,4.2E-10,-90.decimal并不是python内置支持,需要先导入后才能使用。Python 3.4.3 (default, Nov 28 2017, 16:41:13) [GCC 4.8.4] on linuxType 'help', 'copyright', 'credits' or 'license' for more information.>>> f = 3.1415926>>> f3.1415926>>> type(f)
复数类型是python特有的支持类型,在其它的语言中通常不被支持。complex 例如:6.23+1.5j,-1.23-875JPython 3.4.3 (default, Nov 28 2017, 16:41:13) [GCC 4.8.4] on linuxType 'help', 'copyright', 'credits' or 'license' for more information.>>> c = 6.23+1.5j>>> c(6.23+1.5j)>>> type(c)
decimal并不是python的内置类型,使用前需要先导入。