关于python2.7的md5加密遇到的问题(TypeError: Unicode-objects must be en
发布时间:2020-07-30 01:43:06 所属栏目:Python 来源:互联网
导读:https://blog.csdn.net/u012087740/article/details/48439559import hashlibimport sysdef md5s():m=hashlib.md5()strs=sys.argv[1]m.update(strs.encode(utf8))print(m.hexdigest())if __name__==__main__:md5s()注意update()必须指定要加密的字符串的字符编
|
https://blog.csdn.net/u012087740/article/details/48439559 <span style="color: #0000ff;">def<span style="color: #000000;"> md5s():m=<span style="color: #000000;">hashlib.md5() strs=sys.argv[1<span style="color: #000000;">] m.update(strs.encode(<span style="color: #800000;">"<span style="color: #800000;">utf8<span style="color: #800000;">"<span style="color: #000000;">)) <span style="color: #0000ff;">print<span style="color: #000000;">(m.hexdigest()) <span style="color: #0000ff;">if <span style="color: #800080;">name==<span style="color: #800000;">'<span style="color: #800000;">main<span style="color: #800000;">'<span style="color: #000000;">:
注意update()必须指定要加密的字符串的字符编码 (编辑:日照站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- python – 什么是django.utils.functional .__ p
- django-rest-framework序列化器在多个视图中的不
- 突出显示python docstrings作为注释(vim语法高亮
- 【Python有坑系列】函数默认参数
- python – ctypes错误找不到AttributeError符号,
- 在终端上打印python os.urandom输出
- python – 如何从bash脚本中停用virtualenv
- 如何将Python的GTK与gevent集成?
- python – pip install hyperopt和hyperas失败
- python中的Doc,rtf和txt阅读器
热点阅读
