【发布时间】:2019-08-19 23:51:12
【问题描述】:
我能够从 Zillow API 成功调用和检索字典数据。使用 PrettyPrint,我能够检索一个简单的字典。如何提取特定数据?我尝试像普通字典一样在 get_dict 之后运行键,但它没有用。我在下面发布了结果,想知道如何从“zestimate”中提取“金额”。我不熟悉 PrettyPrint 和 get_dict 函数如何协同工作以提取值和键。
import zillow
import pprint
key = "<my key>"
address = "826 Entrada St, Bossier City, LA"
postal_code = "71111"
api = zillow.ValuationApi()
data = api.GetSearchResults(key, address, postal_code)
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(data.get_dict())
{ 'zestimate': { 'amount': 250405,
'amount_change_30days': 228,
'amount_currency': 'USD',
'amount_last_updated': '08/18/2019',
'valuation_range_high': 262925,
'valuation_range_low': 237885},
'zpid': '109815226'}
【问题讨论】:
-
I tried running through keys after the get_dict like a normal dictionary but it didn't work:你尝试了什么? -
我尝试通过 print k, v 为键和值做同样的事情,但没有奏效。