首页 > 学院 > 开发设计 > 正文

python学习笔记十七:base64及md5编码

2019-11-14 17:16:40
字体:
来源:转载
供稿:网友

一、Python Base64编码

Python中进行Base64编码和解码要用base64模块,代码示例:

#-*- coding: utf-8 -*-import base64str = 'VEVb'str64 = base64.b64encode(str)PRint str64                     #Y25ibG9ncw==print base64.b64decode(str64)   #VEVb

二、md5

#Python 2.ximport hashlibprint hashlib.md5("whatever your string is").hexdigest()#Python 3.ximport hashlibprint(hashlib.md5("whatever your string is".encode('utf-8')).hexdigest())

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表