When trying to print the checkmark U + 2713 in Python on Windows you get a UnicodeEncodeError
I have read Print out "statement" sign / checkmark (✓) U + 2713 in Python , but none of the answers work for me. I am running Python 2.7 on Windows.
print u'\u2713'
raises this error:
exceptions.UnicodeEncodeError: 'charmap' codec cannot encode characters in position 0-1: character maps on
It:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
print '✓'
doesn't work because i am using windows.
print u'\u2713'.encode('utf8')
Outputs "-", which is not a valid character.
print('\N{check mark}')
It's just stupid. It prints \N{check mark}
literally.
source to share
Read http://www.joelonsoftware.com/articles/Unicode.html and you can see what's going on.
Bad news: you won't be able to print this character because it simply isn't available in the default text encoding of your Windows terminal. Change your terminal configuration to use "utf-8" instead of the standard "cp-852" or whatever the default cmd window these days, and you should be fine, but only after reading this article seriously.
source to share