1、encode,decode:用来编码和 解码文件的,也可以对StringIO里的数据做编解码
2、encodestring,decodestring:用来编码和解码字符串
3、b64encode和b64decode:用来编码和解码字符串,并且有一个替换符号字符的功能
小实例:
#@小五义 http://www.cnblogs.com/xiaowuyi#将c盘下1.txt(base64编码的内容)解码后存在c盘下2.txt中import base64 filea = open(r'c:\1.txt','r') lines = filea.readlines() writefile=open(r'c:\2.txt','w')for i in lines: word = i.strip() b = base64.decodestring(word) print b writefile.write(b) writefile.write('\n') writefile.close() filea.close()
转载请注明:@小五义 http://www.cnblogs.com/xiaowuyi