I would like to use the playing card characters in unicode within a jupyter notebook.
Unicode codes are here. https://en.wikipedia.org/wiki/Playing_cards_in_Unicode
Printing the suits works
print('\u2660')
returns
ā
As an example, the Ace of Spades š” unicode is U+1F0A1.
I can paste that character and print it.
print('š”')
And I can encode this
'š”'.encode('utf-8')
b'\xf0\x9f\x82\xa1'
But how do I print this by the code "U+1F0A1" from wikipedia?
There is another type of escape code (capital U) that requires eight digits:
>>> print('\U0001F0A1')
š”
You can also print by converting a number:
>>> chr(0x1f0a1)
'š”'
>>> print(chr(0x1f0a1))
š”
So you can programmatically generate a 52-card desk as:
>>> suit = 0x1f0a0,0x1f0b0,0x1f0c0,0x1f0d0
>>> rank = 1,2,3,4,5,6,7,8,9,10,11,13,14
>>> for s in suit:
... for r in rank:
... print(chr(s+r),end='')
... print()
...
š”š¢š£š¤š„š¦š§šØš©šŖš«šš®
š±š²š³š“šµš¶š·šøš¹šŗš»š½š¾
ššššš
šššššššš
ššššššššššššš
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With