如何将unicode数组转换为Python中的字符串

问题描述:

我对Python非常新颖,我试图从我从服务器中检索的unicode数组中打印单个对象。我的阵列是这样的,当我打印结果:如何将unicode数组转换为Python中的字符串

{u'results': [{u'playerName': u'Sean Plott', u'score': u'12'}] 

我想在playerName打印结果作为唯一的字符串。提前致谢。

+0

为什么要转变呢?你也错过了大括号。应该是:'{u'results':[{u'playerName':u'Sean Plott',u'score':u'12'}]}' – dawg

+0

你只是想打印漂亮吗? – dawg

你应该花一些时间在python中查找字典和列表。您目前有一本带有列表的字典,以及该列表中的一本字典。

下面是Python的数据结构的官方参考指南:

https://docs.python.org/3/tutorial/datastructures.html

话虽这么说,这里有一个例子:

>>> d = {u'results': [{u'playerName': u'Sean Plott', u'score': u'12'}]} 
>>> d["results"] 
[{'score': '12', 'playerName': 'Sean Plott'}] 
>>> d["results"][0]["playerName"] 
'Sean Plott' 
+0

他有一个列表,里面有一个字典你的意思 –

+0

他有一个列表字典的字典 – ThiefMaster

+0

谢谢,这让我到了我想要的地方!竖起大拇指 – bbkrz