Base64 encode data: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
|||
Line 1,813: | Line 1,813: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
===Python 2=== |
|||
<syntaxhighlight lang="python">import urllib |
<syntaxhighlight lang="python">import urllib |
||
import base64 |
import base64 |
||
Line 1,819: | Line 1,820: | ||
print base64.b64encode(data)</syntaxhighlight> |
print base64.b64encode(data)</syntaxhighlight> |
||
(For me this gets the wrong data; the data is actually an error message. But still, it base-64 encodes it.) |
(For me this gets the wrong data; the data is actually an error message. But still, it base-64 encodes it.) |
||
===Python 3=== |
|||
<syntaxhighlight lang="python">import base64 # for b64encode() |
|||
from urllib.request import urlopen |
|||
print(base64.b64encode(urlopen('http://rosettacode.org/favicon.ico').read())) |
|||
# Open the URL, retrieve the data and encode the data.</syntaxhighlight> |
|||
=={{header|Racket}}== |
=={{header|Racket}}== |