u'string' スタイルの文字列が散らばっている JSON 文字列を読み込んでいます。例:
[
{
"!\/award\/award_honor\/honored_for": {
"award": {
"id": "\/en\/spiel_des_jahres"
},
"year": {
"value": "1996"
}
},
"guid": "#9202a8c04000641f80000000003a0ee6",
"type": "\/games\/game",
"id": "\/en\/el_grande",
"name": "El Grande"
},
{
"!\/award\/award_honor\/honored_for": {
"award": {
"id": "\/en\/spiel_des_jahres"
},
"year": {
"value": "1995"
}
},
"guid": "#9202a8c04000641f80000000000495ec",
"type": "\/games\/game",
"id": "\/en\/settlers_of_catan",
"name": "Settlers of Catan"
}
]
name = result.name を割り当てた場合。次に、その値を Django テンプレートに渡すことをログに記録すると、u'Dominion' と表示されます。
Dominion として表示するようにフォーマットするにはどうすればよいですか?
++ 更新 ++
問題は、リストまたは辞書から値を出力することに関係していると思います。例えば:
result = freebase.mqlread(query)
games = {}
count = 0
r = result[0]
name = r.name
games["name"] = name,
self.response.out.write(games["name"])
self.response.out.write(name)
これは次のように表示されます。
(u'Dominion',) // saved response to dictionary, and then printed
Dominion // when calling the value directly from the response
JSON 項目の配列を反復処理する必要があり、値が Unicode で表示されています。なんで?