python进行base64编解码

[转]

直接上代码

import base64
fin = open(r"D:\2.zip", "rb")
fout = open(r"D:\2.x.txt", "w")
base64.encode(fin, fout)
fin.close()
fout.close()

fin = open(r"D:\2.x.txt", "r")
fout = open(r"D:\2.x.zip", "wb")
base64.decode(fin, fout)
fin.close()
fout.close()

另外

    decode(input, output)
        Decode a file.
    
    decodestring(s)
        Decode a string.
    
    encode(input, output)
        Encode a file.
    
    encodestring(s)
        Encode a string into multiple lines of base-64 data.

 

posted @ 2014-12-11 15:09  fatterbetter  阅读(1094)  评论(0编辑  收藏  举报