【问题标题】:Obtaining values from Zomato API data keys从 Zomato API 数据键中获取值
【发布时间】:2017-03-22 17:13:19
【问题描述】:

我目前正在尝试从 Zomato API 中的“best_restaurant”列表中获取海沃德餐厅的名称和地址。

我试过了

response = requests.get(url, headers=header)

data = (response.json())

# print(data)

for item in data["best_rated_restaurant"]:
    print item["name"]

我正在接收“best_rated_restaurant”的数据,但不知道如何获取数据中的特定值。

有谁知道我将如何检索数据中的信息,例如姓名、地址、美食等...?

【问题讨论】:

    标签: python api zomato-api


    【解决方案1】:

    你快到了:

    for item in data["best_rated_restaurant"]:
        print item['restaurant']['name']
        print item['restaurant']['location']['address']
        print item['restaurant']['cuisines']
    

    【讨论】:

      猜你喜欢
      • 2020-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-10
      • 2020-11-12
      • 1970-01-01
      • 2017-05-09
      • 2020-02-16
      相关资源
      最近更新 更多