首页 > 其他 > 详细

base64模块 简单了解

时间:2018-08-12 11:06:52      阅读:115      评论:0      收藏:0      [点我收藏+]

base64,字符串文本编码解码,方便数据进行传输

 1 import base64
 2 ‘‘‘编码解码‘‘‘
 3 st = ni hao.encode(utf8)
 4 result = base64.b64encode(st)
 5 print(result)   # b‘bmkgaGFv‘
 6 
 7 result = base64.b64decode(result)
 8 print(result)   # b‘ni hao‘
 9 print(result.decode(utf8))    # ni hao
10 
11 
12 
13 url = https://www.baidu.com.encode(utf8)
14 result = base64.urlsafe_b64encode(url)
15 print(result)   # b‘aHR0cHM6Ly93d3cuYmFpZHUuY29t‘
16 
17 result = base64.urlsafe_b64decode(result)
18 print(result.decode(utf8))    # https://www.baidu.com

 

base64模块 简单了解

原文:https://www.cnblogs.com/pywjh/p/9462175.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!