|  | 
 
| 
本帖最后由 ~风介~ 于 2015-10-27 14:27 编辑
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  
 函数:
 复制代码 b64decode(s, altchars=None, validate=False)
        Decode a Base64 encoded byte string.
        
        s is the byte string to decode.  Optional altchars must be a
        string of length 2 which specifies the alternative alphabet used
        instead of the '+' and '/' characters.
        
        The decoded string is returned.  A binascii.Error is raised if s is
        incorrectly padded.
        
        If validate is False (the default), non-base64-alphabet characters are
        discarded prior to the padding check.  If validate is True,
        non-base64-alphabet characters in the input result in a binascii.Error.
    
    b64encode(s, altchars=None)
        Encode a byte string using Base64.
        
        s is the byte string to encode.  Optional altchars must be a byte
        string of length 2 which specifies an alternative alphabet for the
        '+' and '/' characters.  This allows an application to
        e.g. generate url or filesystem safe Base64 strings.
        
        The encoded byte string is returned.
 
 代码:
 
 复制代码>>> import base64
>>> ff = open('test.txt','rb')
>>> tmp = ff.read()
>>> tmp
b'I Love FishC.com!'
>>> ii = base64.b64encode(tmp)
>>> ii
b'SSBMb3ZlIEZpc2hDLmNvbSE='
>>> jj = base64.b64decode(ii)
>>> jj
b'I Love FishC.com!'
>>> 
 
 
 
 
 | 
 |