What’s the u prefix in a Python string?

You’re right, see 3.1.3. Unicode Strings.

It’s been the syntax since Python 2.0.

Python 3 made them redundant, as the default string type is Unicode. Versions 3.0 through 3.2 removed them, but they were re-added in 3.3+ for compatibility with Python 2 to aide the 2 to 3 transition.

Leave a Comment