Why the inconsistent of those two base64 methods?

Leo Jay python.leojay at gmail.com
Wed May 12 00:04:41 EDT 2010


I'd like to encode a string in base64, but I found a inconsistent of
two methods:

>>> 'aaa'.encode('base64')
'YWFh\n'
>>> import base64
>>> base64.b64encode('aaa')
'YWFh'
>>>


as you can see, the result of
'aaa'.encode('base64')
has a '\n' at the end, but the other method doesn't.

Why the inconsistent?
Thanks.

-- 
Best Regards,
Leo Jay



More information about the Python-list mailing list