To include Unicode characters in your Python source code, you can use Unicode escape characters in the form \u0123 in your string. In Python 2.x, you also need to prefix the string literal with 'u'.

Here's an example running in the Python 2.x interactive console:

>>> print u'\u0420\u043e\u0441\u0441\u0438\u044f'
Россия

In Python 2, prefixing a string with 'u' declares them as Unicode-type variables, as described in the Python Unicode documentation.

In Python 3, the 'u' prefix is now optional:

>>> print('\u0420\u043e\u0441\u0441\u0438\u044f')
Россия

If running the above commands doesn't display the text correctly for you, perhaps your terminal isn't capable of displaying Unicode characters.

These examples use Unicode escapes (\u...), which allows you to print Unicode characters while keeping your source code as plain ASCII. This can help when working with the same source code on different systems. You can also use Unicode characters directly in your Python source code (e.g. print u'Россия' in Python 2), if you are confident all your systems handle Unicode files properly.

For information about reading Unicode data from a file, see this answer:

Character reading from file in Python

Answer from Matt Ryall on Stack Overflow
🌐
Python documentation
docs.python.org › 3 › howto › unicode.html
Unicode HOWTO — Python 3.14.7 documentation
For example, there’s a character for “Roman Numeral One”, ‘Ⅰ’, that’s separate from the uppercase letter ‘I’. They’ll usually look the same, but these are two different characters that have different meanings. The Unicode standard describes how characters are represented by code points. A code point value is an integer in the range 0 to 0x10FFFF (about 1.1 million values, the actual number assigned is less than that).
Top answer
1 of 10
175

To include Unicode characters in your Python source code, you can use Unicode escape characters in the form \u0123 in your string. In Python 2.x, you also need to prefix the string literal with 'u'.

Here's an example running in the Python 2.x interactive console:

>>> print u'\u0420\u043e\u0441\u0441\u0438\u044f'
Россия

In Python 2, prefixing a string with 'u' declares them as Unicode-type variables, as described in the Python Unicode documentation.

In Python 3, the 'u' prefix is now optional:

>>> print('\u0420\u043e\u0441\u0441\u0438\u044f')
Россия

If running the above commands doesn't display the text correctly for you, perhaps your terminal isn't capable of displaying Unicode characters.

These examples use Unicode escapes (\u...), which allows you to print Unicode characters while keeping your source code as plain ASCII. This can help when working with the same source code on different systems. You can also use Unicode characters directly in your Python source code (e.g. print u'Россия' in Python 2), if you are confident all your systems handle Unicode files properly.

For information about reading Unicode data from a file, see this answer:

Character reading from file in Python

2 of 10
54

Print a unicode character in Python:

Print a unicode character directly from python interpreter:

el@apollo:~$ python
Python 2.7.3
>>> print u'\u2713'
✓

Unicode character u'\u2713' is a checkmark. The interpreter prints the checkmark on the screen.

Print a unicode character from a python script:

Put this in test.py:

#!/usr/bin/python
print("here is your checkmark: " + u'\u2713');

Run it like this:

el@apollo:~$ python test.py
here is your checkmark: ✓

If it doesn't show a checkmark for you, then the problem could be elsewhere, like the terminal settings or something you are doing with stream redirection.

Store unicode characters in a file:

Save this to file: foo.py:

#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
import codecs
import sys 
UTF8Writer = codecs.getwriter('utf8')
sys.stdout = UTF8Writer(sys.stdout)
print(u'e with obfuscation: é')

Run it and pipe output to file:

python foo.py > tmp.txt

Open tmp.txt and look inside, you see this:

el@apollo:~$ cat tmp.txt 
e with obfuscation: é

Thus you have saved unicode e with a obfuscation mark on it to a file.

🌐
GeeksforGeeks
geeksforgeeks.org › python › working-with-unicode-in-python
Working with Unicode in Python - GeeksforGeeks
July 23, 2025 - Python's unicodedata module provides the normalize() function for normalizing Unicode strings. The normalization forms include NFD, NFC, NFKD, and NFKC. Below, code demonstrates the effects of different normalization forms on string lengths. NFD decomposes characters, while NFC composes them. Similarly, NFKD and NFKC are used for "strict" normalization. ... from unicodedata import normalize s1 = 'hôtel' s2 = 'ho\u0302tel' s1_nfd = normalize('NFD', s1) print(len(s1), len(s1_nfd)) s2_nfc = normalize('NFC', s2) print(len(s2), len(s2_nfc))
🌐
GitHub
gist.github.com › seanh › 0a56cd528714496625662dd9136d0cd3
Unicode in Python · GitHub
Each code point also has an all-caps ASCII name like DOUBLE-STRUCK CAPITAL P. In literal unicode strings in Python a unicode code point like U+2119 can be written with \u like "\u2119":
🌐
Real Python
realpython.com › python-encodings-guide
Unicode & Character Encodings in Python: A Painless Guide – Real Python
May 20, 2019 - For example, the number 65536 or 216, is just 10000 in hexadecimal, or 0x10000 as a Python hexadecimal literal. ... As you saw, the problem with ASCII is that it’s not nearly a big enough set of characters to accommodate the world’s set ...
🌐
Real Python
realpython.com › ref › glossary › unicode
Unicode | Python Glossary – Real Python
>>> import unicodedata >>> # Normalize to NFC (composed form) >>> unicodedata.normalize("NFC", text) 'Hello, 世界 🌍' Mixing encodings: Always know what encoding your data uses. Assuming one character = one code point: Some characters require multiple code points—for example, emojis with skin tones.
🌐
Python Cheat Sheet
pythonsheets.com › notes › basic › python-unicode.html
Unicode — Python Cheat Sheet
For example, the character, é can be written as e ́ (Canonical Decomposition) or é (Canonical Composition). In this case, we may acquire unexpected results when we are comparing two strings even though they look alike.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-work-with-unicode-in-python
How To Work with Unicode in Python | DigitalOcean
The tutorial will cover the basics of Unicode in Python and how Python interprets Unicode characters. It covers the concepts of unicodedata and how to use th…
Find elsewhere
🌐
Linode
linode.com › docs › guides › how-to-use-unicode-in-python3
Using Unicode in Python 3 | Linode Docs
March 20, 2023 - The Unicode code point for the musical note symbol ♩ is 0x2669. This symbol can be assigned to a Python string using its hexadecimal equivalent. ... The escape sequence for a Unicode character requiring three or four bytes begins with \U. The hexadecimal value must contain eight digits, so pad the front of the value with zeros until it is the proper length. For example, the Unicode bumblebee emoji is encoded in a three-byte format possessing the Unicode code point U+1F41D...
🌐
TutorialsPoint
tutorialspoint.com › unicode-string-in-python
Unicode String in Python
January 28, 2020 - # Encoding Unicode to bytes text = "Hello ??" encoded = text.encode('utf-8') print(f"Original: {text}") print(f"Encoded: {encoded}") # Decoding bytes back to Unicode decoded = encoded.decode('utf-8') print(f"Decoded: {decoded}") Original: Hello ?? Encoded: b'Hello \xe4\xb8\x96\xe7\x95\x8c' Decoded: Hello ?? ... text = "Hello123???" print(f"Is alphanumeric: {text.isalnum()}") print(f"Is alpha: {text.isalpha()}") print(f"Is ASCII: {text.isascii()}") print(f"Length: {len(text)}") Is alphanumeric: True Is alpha: False Is ASCII: False Length: 11 · Python 3 handles Unicode seamlessly with all strings being Unicode by default.
🌐
B-List
b-list.org › weblog › 2017 › sep › 05 › how-python-does-unicode
How Python does Unicode - James Bennett
September 5, 2017 - To create a str in Python 2, you can use the str() built-in, or string-literal syntax, like so: my_string = 'This is my string.'. To create an instance of unicode, you can use the unicode() built-in, or prefix a string literal with a u, like so: my_unicode = u'This is my Unicode string.'.
🌐
UW PCE
uwpce-pythoncert.github.io › SystemDevelopment › unicode.html
Unicode in Python 2 — System Development With Python 2.0 documentation
In [1]: s = "this is a regular py2 string" In [2]: print type(s) <type 'str'> In [3]: from __future__ import unicode_literals In [4]: s = "this is now a unicode string" In [5]: type(s) Out[5]: unicode · NOTE: You can still get py2 strings from other sources! ... ASCII compatible means in may work with default encoding in tests – but then blow up with real data... Kind of like UTF-8, except it uses at least 16bits (2 bytes) for each character: not ASCII compatible. But is still needs more than two bytes for some code points, so you still can’t process · In C/C++ held in a “wide char” or “wide string”.
🌐
Pylonsproject
docs.pylonsproject.org › projects › pylons-webframework › en › latest › tutorials › understanding_unicode.html
Understanding Unicode — Pylons Framework 1.0.2 documentation
Here is an example demonstrating the different alternatives: >>> s = u"\x66\u0072\u0061\U0000006e" + unichr(231) + u"ais" >>> # ^^^^ two-digit hex escape >>> # ^^^^^^ four-digit Unicode escape >>> # ^^^^^^^^^^ eight-digit Unicode escape >>> for c in s: print ord(c), ... 97 102 114 97 110 231 ...
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python string unicode
Python String Unicode - Spark By {Examples}
May 21, 2024 - How to convert string to Unicode characters in Python? Strings in Python are sequences of characters that are used to represent text. Unicode is a
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › unicode.html
unicode — Python Reference (The Right Way) 0.1 documentation
If no optional parameters are given, unicode() will mimic the behaviour of str() except that it returns Unicode strings instead of 8-bit strings.
🌐
AskPython
askpython.com › python-modules › unicode-in-python-unicodedata
Unicode In Python - The unicodedata Module Explained - AskPython
February 16, 2023 - A string is a sequence of Unicode codepoints. These codepoints are converted into a sequence of bytes for efficient storage. This process is called character encoding. There are many encodings such as UTF-8,UTF-16,ASCII etc. By default, Python uses UTF-8 encoding.
🌐
Python
docs.python.org › 3 › c-api › unicode.html
Unicode Objects and Codecs — Python 3.14.7 documentation
If necessary, the input buffer ... example, if the buffer is a UCS4 string (PyUnicode_4BYTE_KIND) and it consists only of codepoints in the UCS1 range, it will be transformed into UCS1 (PyUnicode_1BYTE_KIND)....
🌐
GeeksforGeeks
geeksforgeeks.org › python › unicode_literals-in-python
unicode_literals in Python - GeeksforGeeks
June 21, 2021 - If we are using an older version of python, we need to import the unicode_literals from the future package. This import will make python2 behave as python3 does. This will make the code cross-python version compatible. ... import sys # checking the default encoding of string print "The default encoding for python2 is:", sys.getdefaultencoding() ... As in python2, the default encoding is ASCII we need to switch the encoding to utf-8.