2015-06-23 38 views

回答

0

对于编码为base64使用base64模块及其为该函数b64encode

实施例。 -

>>> import base64 
>>> base64.b64encode("Hello") 
'SGVsbG8=' 
>>> s = 'A0[Bt\"V59.xA-bKO|/A\"\"/Z.!#Y:wfpR' 
>>> base64.b64encode(s) 
'QTBbQnQiVjU5LnhBLWJLT3wvQSIiL1ouISNZOndmcFI=' 

对于解码,使用b64decode()功能 -

>>> import base64 
>>> base64.b64decode('SGVsbG8=') 
'Hello' 
>>> base64.b64decode('QTBbQnQiVjU5LnhBLWJLT3wvQSIiL1ouISNZOndmcFI=') 
'A0[Bt"V59.xA-bKO|/A""/Z.!#Y:wfpR'