Print the "approval" sign/check mark (✓) U+2713 in Python

Question:

How can I print the check mark sign “✓” in Python?

It’s the sign for approval, not a square root.

Asked By: Mauro

||

Answers:

You can print any Unicode character using an escape sequence. Make sure to make a Unicode string.

print u'u2713'
Answered By: Jerome

Like this:

print u'u2713'.encode('utf8')

The encoding should match the one of your terminal (or wherever you are sending output to).

Answered By: lenz

Solution defining python source file encoding:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

print '✓'

http://ideone.com/dTW5D8

Answered By: oblitum

Since Python 2.1 you can use N{name} escape sequence to insert Unicode characters by their names. Using this feature you can get check mark symbol like so:

$ python -c "print(u'N{check mark}')"
✓

Note: For this feature to work you must use unicode string literal. u prefix is used for this reason. In Python 3 the prefix is not mandatory since string literals are unicode by default.

Answered By: Mr. Deathless
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.