base64.urlsafe_b64encode(s) in Python
Last Updated :
26 Mar, 2020
With the help of base64.urlsafe_b64encode(s)
method, we can encode the string using url and file system safe alphabets into the binary form.
Syntax : base64.urlsafe_b64encode(s)
Return : Return the encoded string.
Example #1 :
In this example we can see that by using base64.urlsafe_b64encode(s)
method, we are able to get the encoded string which can be in binary form by using this method.
from base64 import urlsafe_b64encode
s = b 'GeeksForGeeks'
gfg = urlsafe_b64encode(s)
print (gfg)
|
Output :
b’R2Vla3NGb3JHZWVrcw==’
Example #2 :
from base64 import urlsafe_b64encode
s = b 'www.python.org / documentation'
gfg = urlsafe_b64encode(s)
print (gfg)
|
Output :
b’d3d3LnB5dGhvbi5vcmcvZG9jdW1lbnRhdGlvbg==’
Share your thoughts in the comments
Please Login to comment...