Base64码转换的python实现源码,base64python,为了方便测试时使用,写了
Base64码转换的python实现源码,base64python,为了方便测试时使用,写了
为了方便测试时使用,写了段小代码,完成将字符串、文件转换为Base64码,并能将相应的Base64码再转为字符串、文件的方法。需要用到python base64方法。
#! /usr/bin/env python#coding=utf-8import base64a = input("Enter string:")b = base64.encodestring(a) # Encode for stringprint bprint base64.decodestring(b) # Decode for stringf = open('temp.jpg','rb')c = f.read()x = base64.encodestring(c) # Encode for filef.close()print len(x)print "".join(x.split())base64.decodestring(x) # Decode for filefile1 = open('temp','wb')file1.write(base64.decodestring(x))#www.iplaypy.com
编橙之家文章,
相关内容
- 用scp备份openstack的instance镜像方法,scpopenstack,以下pyt
- Python xlrd方法实现excel数据查找提取保存操作,pythonxl
- web.py能条件判断的页面执行计时方法,web.py计时,编橙之
- Blowfish加密解密的Python实现方法,blowfishpython,Blowfish加密
- 用VBS脚本读英语的Python代码分享,vbs脚本英语python,这是
- Python print输出彩色字符的方法,pythonprint,Python print
- 依赖Tkinter完成的简单记事本,依赖tkinter记事本,这是我
- 控制台进度自动刷新python方法源码,自动刷新python,要实
- 导出Gmail、网易邮箱联系人名单的python方法,gmailpytho
- 在CSV文件中添加联系人的python方法,csvpython,学习Pytho
评论关闭