![](/img/trans.png)
[英]How to convert a string with unicode in it to unicode using python
[英]How to convert unicode array to string in Python
我是Python的新手,我正嘗試從我從服務器檢索的unicode數組中打印單個對象。 當我打印結果時,我的數組如下所示:
{u'results': [{u'playerName': u'Sean Plott', u'score': u'12'}]
我只想將結果在playerName
打印為字符串。 提前致謝。
您應該花一些時間在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'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.