测试环境
- Python 3.9.12
- feapder 1.7.9
方案一
from hashlib import md5
print(md5(str('123' + '456').encode('utf8')).hexdigest())
运行结果
e10adc3949ba59abbe56e057f20f883e
方案二
from feapder.utils import tools
print(tools.get_md5('123' + '456'))
运行结果
e10adc3949ba59abbe56e057f20f883e
说明
- 方案一中的依赖库为Python自带,方案二需要手动安装第三方库
feapder
。 - 方案二是对方案一的封装。
- tools中类似的方法还有
get_sha1()
、get_base64()
、get_uuid()
、get_hash()