Python & # 8594; how to print "block" using ascii # 219 on mac

I am using python for mac osx, I want to use extended ascii # 219, as in this table:

http://www.theasciicode.com.ar/extended-ascii-code/graphic-character-ascii-code-178.html

The problem is, I found out that the symbol "block" does not exist in mac ascii ... I'm not sure. Can someone help me? try printing with unichr (219) giving me a different result. he will output → Û. what i want → █

Thanx

+3
source share
3 answers

the corresponding unicode0x2588 character is equal , so use this:

print unichr(0x2588)        # or:
print u"\u2588"

should give you the correct result. if you want it in a different encoding, you can always have encodeit.

+11

ASCII Mac, unicode .

+2

, , 219, 9608. :

python3:

>>> ord("█")
9608
>>> chr(9608)
'█'

python2:

>>> unichr(9608)
u'\u2588'
>>> print(u'\u2588')

if you still have problems, set your teminal to use utf-8 and .encode()in utf-8, if necessary.

+1
source

All Articles