我一直在尝试解析这个OrderedDict,以便从下面的SQL返回中获得'Id‘值。
OrderedDict([
('totalSize', 1),
('done', True),
('records', [OrderedDict([
('attributes', OrderedDict([
('type', 'Device__c'),
('url', '/services/data/v38.0/sobjects/Device__c/a001r00000qCgp1AAC')])),
('Id', 'a001r00000qCgp1AAC')])])])以下是print(query_result['records'])。我还能走得更远吗?
OrderedDict([
('attributes', OrderedDict([
('type', 'Device__c'),
('url', '/services/data/v38.0/sobjects/Device__c/a001r00000qCgp1AAC')])),
('Id', 'a001r00000qCgp1AAC')])]感谢您的宝贵时间。
发布于 2018-08-09 19:20:03
您需要迭代records密钥
Ex:
for i in query_result["records"]:
print( i["Id"] )或者,如果列表中只有一个元素,则可以使用index。
Ex:
print( query_result["records"][0]["Id"])https://stackoverflow.com/questions/51765515
复制相似问题