Python 2.7 如何在boto3 python2.7 list dict object-list_tags_中搜索_资源的值
我有一个物体在下面Python 2.7 如何在boto3 python2.7 list dict object-list_tags_中搜索_资源的值,python-2.7,boto3,Python 2.7,Boto3,我有一个物体在下面 response = source.list_tags_for_resource(ResourceName=<ARN>) taglistk = response['TagList'] print(taglistk) 现在,我想写一个for if条件,只匹配K,V az=yes和service=mariadb,并从响应的标记列表中执行一些操作,选择一个tag by for循环并检查给定键的值,即Key和Value response = source
response = source.list_tags_for_resource(ResourceName=<ARN>)
taglistk = response['TagList']
print(taglistk)
现在,我想写一个for if条件,只匹配K,V az=yes和service=mariadb,并从响应的标记列表中执行一些操作,选择一个tag by for循环并检查给定键的值,即Key和Value
response = source.list_tags_for_resource(ResourceName=<ARN>)
for item in response:
if item['Key'] == 'az' and item['Value'] == 'yes':
# do something with item
elif item['Key'] == 'service' and item['Value'] == 'mariadb':
# do otherthing with item
else:
continue
response=source。列出资源(ResourceName=)的标签
答复项目:
如果项目['Key']='az'和项目['Value']='yes':
#对这个项目做些什么
elif项目['Key']=='service'和项目['Value']=='mariadb':
#对物品做其他事情
其他:
持续
实际上,在对这些项目进行任何操作之前,我必须检查这两个条件。首先,如果条件应检查k、v对,并采取措施。它们是分开的项目,一个项目如何同时满足这两个条件?我不明白你的意思。
response = source.list_tags_for_resource(ResourceName=<ARN>)
for item in response:
if item['Key'] == 'az' and item['Value'] == 'yes':
# do something with item
elif item['Key'] == 'service' and item['Value'] == 'mariadb':
# do otherthing with item
else:
continue