列表中的“u"是什么意思? [英] What does 'u' mean in a list?
本文介绍了列表中的“u"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我第一次遇到这种情况.刚刚打印了一个列表,每个元素前面似乎都有一个 u
,即
[u'hello', u'hi', u'hey']
这是什么意思?为什么列表的每个元素前面都有这个?
因为我不知道这有多常见,如果你想看看我是怎么遇到它的,我很乐意编辑帖子.
解决方案
表示 unicode 字符串.类似于 r''
用于原始字符串.
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.
解决方案
it's an indication of unicode string. similar to r''
for raw string.
>>> type(u'abc')
<type 'unicode'>
>>> r'ab\c'
'ab\\c'
这篇关于列表中的“u"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文