Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'u' mean in a list?

This is the first time I've came across this. Just printed a list and each element seems to have a u in front of it i.e.

[u'hello', u'hi', u'hey']

What does it mean and why would a list have this in front of each element?

As I don't know how common this is, if you'd like to see how I came across it, I'll happily edit the post.

like image 473
Federer Avatar asked Sep 11 '25 08:09

Federer


2 Answers

it's an indication of unicode string. similar to r'' for raw string.

>>> type(u'abc')
<type 'unicode'>
>>> r'ab\c'
'ab\\c'
like image 194
SilentGhost Avatar answered Sep 12 '25 22:09

SilentGhost


Unicode.

like image 37
mculp Avatar answered Sep 12 '25 23:09

mculp