I am working on a little euchre project for those of you who are familiar with that. I need suit symbols to identify the cards in my game. Unicode seems to be the best way of doing that.
I am using Eclipse for IDE developers coupled with a pydev module. It's running Python 3.0.
It should just be as simple as:
club = u"\u2663".encode('utf-8')
print(club)
My output is literally:
>>> b'\xe2\x99\xa3'
What am I missing?
Don't encode; the sys.stdout
file stream is opened with your terminal encoding and encodes unicode for you:
club = u"\u2663"
print(club)
You don't need to use u''
; python 3 strings are unicode values by default .
Demo:
>>> club = "\u2663"
>>> print(club)
♣
That you shouldn't need to encode.
3>> print('\u2663')
♣
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.