簡體   English   中英

如何在Python中將Unicode數組轉換為字符串

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM