To summarize: How do I print the Unicode system myself to create game card characters?
What I am doing wrong, I believe that I am fairly fluent in Python, except that I do not seem to be able to type correctly!
from __future__ import print_function
from __future__ import unicode_literals
import sys
symbols = ('♥','♦','♠','♣')
print(' '.join(symbols[:2]), file=sys.stderr)
print(' '.join(symbols[2:]))
sys.stdout.write(symbols)
print(' '.join(symbols))
Printing to the console, which is the main one for the console application, is unsuccessful, although:
J:\test>chcp
Aktiivinen koodisivu: 850
J:\test>symbol2
Traceback (most recent call last):
File "J:\test\symbol2.py", line 9, in <module>
print(''.join(symbols))
File "J:\Python26\lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-3: character maps to <unde
fined>
J:\test>chcp 437
Aktiivinen koodisivu: 437
J:\test>d:\Python27\python.exe symbol2.py
Traceback (most recent call last):
File "symbol2.py", line 6, in <module>
print(' '.join(symbols))
File "d:\Python27\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2660' in position 0: character maps
o <undefined>
J:\test>
So, summa summaryum I have a console application that runs until you use the console, but IDLE.
I can, of course, generate the characters myself by creating them using chr:
print(''.join(chr(n) for n in range(3,3+4)))
But it looks a very silly way. And I do not run programs only on Windows or have many special cases (for example, conditional compilation). I need readable code.
, , , , Nokia, Windows Linux. ,