base64.b64encode() in Python
With the help of base64.b64encode()
method, we can encode the string into the binary form.
Syntax : base64.b64encode(string)
Return : Return the encoded string.
Example #1 :
In this example we can see that by using base64.b64encode()
method, we are able to get the encoded string which can be in binary form by using this method.
from base64 import b64encode
s = b 'GeeksForGeeks'
gfg = b64encode(s)
print (gfg)
|
Output :
b’R2Vla3NGb3JHZWVrcw==’
Example #2 :
from base64 import b64encode
s = b 'I love python'
gfg = b64encode(s)
print (gfg)
|
Output :
b’SSBsb3ZlIHB5dGhvbg==’
Last Updated :
26 Mar, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...