>>> import base64 >>> encoded = base64.b64encode(b'data to be encoded') >>> encoded b'ZGF0YSB0byBiZSBlbmNvZGVk' >>> data = base64.b64decode(encoded) >>> data b'data to be encoded' #类似的方法base64.encodebytes(s),这个方法返回多行数据(看不懂),反正末尾总是跟着\n