Base64 encode data: Difference between revisions
→{{header|Python}}
(Added XPL0 example.) |
|||
Line 1,813:
=={{header|Python}}==
===Python 2===
<syntaxhighlight lang="python">import urllib
import base64
Line 1,819 ⟶ 1,820:
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.)
===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}}==
|