1

The u is present in front of every value in the following example:

enter image description here

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Dodo
  • 51
  • 1
  • 6

1 Answers1

1

The ‘u’ in front of a string means the string is a Unicode string.

A Unicode is a way for a string to represent more characters than a regular ASCII string can.

In Python 2.x shell, you can see how for example a text written in Russian converts to a Unicode string with ‘u’ in front of it and a bunch of Unicode characters in it:

>>> hello_rus = u"Привет, мир"
>>> hello_rus
u'\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0438\u0440'

In Python 2.x, a Unicode string is marked with ‘u’.

However, in Python 3 all strings are Unicode strings by default. Thus you will never see ‘u’ in front of a Unicode string in Python 3.

Content copied from: Python What Does ‘u’ Mean in Front of a String

Arulkumar
  • 12,966
  • 14
  • 47
  • 68