math模块
用int强转会直接去掉小数点后面的值,如下
print(int(12.9999)) # 12
print(int(-12.78)) # -12
ceil(浮点数) - 将浮点数转换成整数(向大取整)
print(math.ceil(12.9)) # 13
print(math.ceil(-12.9)) # -12
floor(浮点数) - 将浮点数转换成整数(向小取整)
print(math.floor(12.99)) # 12
print(math.floor(-12.9)) # -13
complex:复数对应的数学类型
a = 10+2j # 数学中的i在程序中用j表示
print(type(a)) # 查看类型
hashlib模块
- hash加密的摘要(密文)是不可逆的
- 相同的数据通过相同的算法生成的摘要(密文)是一样的
- 不同大小的数据通过相同的算法生成的摘要(密文)的长度是一样的
hash相关的算法:md5和shaXXX(不同的长度(xxx)代表摘要长度不