Kann Unicode-Bitcoin-Symbol in Python 2 nicht drucken
Ich versuche, das Unicode-Bitcoin-Symbol zu drucken\u2043
in Python 2. Ich habe versucht, @ hinzuzufüg#-*- coding: utf-8 -*-
.
$ python2 -c 'print u'\u0243''
RaisesUnicodeEncodeError: 'ascii' codec can't encode character u'\u0243' in position 0: ordinal not in range(128)
. Dies funktioniert jedoch über die Python-Shell.
$ python2
>>> print u'\u0243'
Ƀ
Warum funktioniert dieser Code nicht?
bitcoin = u'\u0243'
quote = u'{:,.2f}'.format(float(val), '.2f')
print bitcoin, quote