2019年6月16日 hashlib 模块

hashlib 模块 用于加密相关操作——————摘要算法

import hashlib
obj=hashlib.md5()#md5加密
obj2=hashlib.md5('sxj'.encode('utf8'))#md5加严
obj.update('hello'.encode('utf8'))
obj2.update('hello'.encode('utf8'))
print(obj.hexdigest())
print(obj2.hexdigest())

obj.update('abc'.encode('utf-8'))#相当于在hello基础上又加密了abc,也就是等同于加密了helloabc
print(obj.hexdigest())
s='1 -2 * (2-2/4)'
ret=s.replace(' ','')#替换空格
print(ret)
原文地址:https://www.cnblogs.com/python1988/p/11032648.html