How can I print a euro (â¬) symbol in Python?
<p>I'm teaching myself Python using the command-line interpreter (v3.5 for Windows).</p>

<p><strong>All I want to do is output some text that includes the euro (â¬) symbol</strong> which I understand to be code 80h (128 dec).</p>

<pre><code>#!
# -*- coding: utf-8 -*-

mytext = 'Please pay \x8035.'
print(mytext)
</code></pre>

<p>It falls over on the last line:</p>

<pre><code>UnicodeEncodeError: 'charmap' codec can't encode character '\x80' in position 11: character maps to &lt;undefined&gt;
</code></pre>

<p>I've done lots of googling (re encodings etc) and I've a rough idea why the print command fails. Tinkering with the above code shows that ASCII codes up to \x7f work fine, as one might expect.</p>

<p>But I can't figure out how to display the <strong>â¬</strong>, and I'm finding the information on encodings overwhelming and impenetrable. (Remember I'm just a noob!)</p>

<ul>
<li>I've tried prefixing the text string with <em>u</em> to create a unicode string in the first place.</li>
<li>I've tried creating an intermediate object <em>outputtext = mytext.encode('utf-8')</em> but outputting this with <em>print</em> expands the string into an even more cryptic form: <em>b'Please pay \xc2\x8035.'</em></li>
<li>I've tried to find a different function instead of <em>print</em> to output this intermediate string, but nothing has worked yet.</li>
</ul>

<p>Please can someone show me some code that <strong>just works</strong>, so I can study it and work backwards from there. Thanks!</p>

<p>In Python 3, you can simply copy and paste the â¬ character directly into a UTF-8 encoded text file (no need for codes):</p>

<pre><code>mytext = 'Please pay â¬.'
print(mytext)
</code></pre>

python utf-8 character-encoding