我如何选择' FirstName'在Python中使用OrderedDict?
OrderedDict([(u'totalSize', 1),
(u'done', True),
(u'records',
[OrderedDict([
(u'attributes',
OrderedDict([
(u'type', u'Contact'),
(u'url',u'/services/data/v38.0/sobjects/Contact/003290000089vSgAAI')])),
(u'FirstName', u'John'), (u'LastName', u'Smith')])])])
答案 0 :(得分:0)
>>> from collections import OrderedDict
>>> a = OrderedDict([('totalSize', 1), ('done', True), ('records', [OrderedDict([('attributes', OrderedDict([('type', 'Contact'), ('url', '/services/data/v38.0/sobjects/Contact/003290000089vSgAAI')])), ('FirstName', 'John'), ('LastName', 'Smith')])])])
>>> a['records'][0]['FirstName']
'John'
内部OrderedDict对象在列表中(此列表仅包含OrderedDict对象)