Printing a unicode character in Python:
Printing a unicode character directly from a python interpreter:
el@apollo:~$ python Python 2.7.3 >>> print u'\u2713' ✓
The unicode character u'\u2713' is a check mark. The interpreter prints a check mark on the screen.
Print unicode character from python script:
Put this in test.py:
#!/usr/bin/python print("here is your checkmark: " + u'\u2713');
Run it as follows:
el@apollo:~$ python test.py here is your checkmark: ✓
If it does not show a checkmark for you, the problem may be in another place, for example, the terminal settings or something that you do with redirecting the stream.
Save Unicode characters in a file:
Save this to a file: foo.py:
#!/usr/bin/python -tt
Run it and output the file to a file:
python foo.py > tmp.txt
Open tmp.txt and look inside, you will see the following:
el@apollo:~$ cat tmp.txt e with obfuscation: é
Thus, you saved unicode e with an obfuscation mark on it to a file.
Eric Leschinski Dec 07 '13 at 23:20 2013-12-07 23:20
source share