如何从google books API python返回的JSON对象中访问值?

如何从google books API python返回的JSON对象中访问值?,python,json,google-books,Python,Json,Google Books,我正在从python脚本访问GoogleBooksAPI,我需要在我得到的JSON对象中获取一个特定值。例如,如果您遵循以下步骤: 您将看到我尝试使用的JSON对象。我需要取description键中包含的图书描述。我正在使用json.load在使用urlib2获取后加载它 我尝试过做以下几件事,但都无济于事: a = json.load(urllib2.urlopen('https://www.googleapis.com/books/v1/volumes?q=9781607055389')

我正在从python脚本访问GoogleBooksAPI,我需要在我得到的JSON对象中获取一个特定值。例如,如果您遵循以下步骤:

您将看到我尝试使用的JSON对象。我需要取
description
键中包含的图书描述。我正在使用
json.load
在使用
urlib2
获取后加载它

我尝试过做以下几件事,但都无济于事:

a = json.load(urllib2.urlopen('https://www.googleapis.com/books/v1/volumes?q=9781607055389'))
print a.items[0].description

description
在另一本词典中,您已经忘记了:

>>> print a['items'][0]['volumeInfo']['description']
Photo tutorials show stitching in action for 50+ free-motion quilting designs to create modern quilts with classic style! Popular blogger and designer, Natalia Bonner, illustrates her instructions with detailed photos that make it easier to get beautiful results on your home sewing machine. Learn how to quilt all-over, as filler, on borders, and on individual blocks...using loops and swirls, feathers and flames, flowers and vines, pebbles and more! Includes tips for choosing batting and thread, layering and basting, starting and stopping, and prepping your machine are included. After you've practiced, show off your new skills with six geometric quilt projects.

访问字典值的意图与python中的不同。您可以使用
get()
函数,也可以执行我所做的操作。之所以
.items
有效,是因为内置函数
.items()
,它返回字典的结构。

请尝试使用以下方法:

a['items'][0]['volumeInfo']['description']

注意,a.items()和a['items']不是一回事。a、 items()提供元组列表中的键、值对。

感谢您为我清理这些。我对
.items()
为什么起作用感到困惑。