4
I am starting in Python and come from PHP.
To convert a string to base 64 in PHP, I do it as follows:
base64_encode('stack overflow'); //c3RhY2sgb3ZlcmZsb3c=
And in the Python, how do I do that?
4
I am starting in Python and come from PHP.
To convert a string to base 64 in PHP, I do it as follows:
base64_encode('stack overflow'); //c3RhY2sgb3ZlcmZsb3c=
And in the Python, how do I do that?
9
It’s like that. You just have to make one import:
>>> import base64
>>> encoded = base64.b64encode(b'stack overflow')
b'c3RhY2sgb3ZlcmZsb3c='
b64encode asks for an array of bytes, not a string. The b on the front make this conversion.
Why did you use b'stack' instead of just 'stack'? Binary?
Because b64encode asks for an array of bytes, not a string. O b on the front make this conversion.
Browser other questions tagged python
You are not signed in. Login or sign up in order to post.
http://answall.com/questions/92791/existe-alguma-forma-de-converter-uma-string-para-base-64-em-javascript?answertab=votes#tab-top
– Wallace Maxters