[英]Extracting Dictionary Value from a Tuple
I have a tuple which is basically like this: 我有一个基本上是这样的元组:
t=(OrderedDict([('attributes', OrderedDict([('type', 'User'), ('url', '/services/data/v38.0/sobjects/User/0006Cx6pIAC')])), ('Name', 'Ben Dams')]),)
How do I extract just the 'Name' from the dictionary? 如何仅从字典中提取“名称”?
You have a single-value tuple which contains a dictionary. 您有一个包含字典的单值元组。 So just use indexing before accessing a dictionary key:
因此,只需在访问字典键之前使用索引:
res = t[0]['Name'] # 'Ben Dams'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.