1、在python在数值的类型大概包括int float complex decimal
1、int 在3.x中它不在有最大值的限制。
2、float它更加连近于C语言中的double
3、complex 复数据类型。
4、decimal 支持用户自定义精度的类型。
例子:把一个二进制的序列转化成int 类的整数。
#!/usr/bin/python #!coding:utf-8 #!以下程序要用到python3.5 if __name__=="__main__": #int.from_bytes(bytearry,byteOrder,signed) #big 更加符合人类的使用习惯、然而计算机一般默认是little 以下三个都是10的二进制形式 print(int.from_bytes(b'x00x0a','big',signed=True)) print(int.from_bytes(b'x0ax00x00x00','little',signed=False)) print(int.from_bytes(b' x00x00x00','little',signed=False))
如果我们想要知道我们当前系统用的是big还是little 时怎么办呢?
答案就是sys.byteorder