繁体   English   中英

如何将boto3过滤器用于布尔值

[英]how to use boto3 Filters for boolean value

我在python 3.5.2中使用boto 3试图描述ec2图像。 医生说可用的过滤器之一是“公开”的:

is-public - A Boolean that indicates whether the image is public.

但是Filter语法只需要一个字符串列表-仅一个字符串列表作为Value。 如果我尝试传递布尔值,则会给我一个类型错误:

Invalid type for parameter Filters[0].Values[0], value: False, type: <class 'bool'>, valid types: <class 'str'>

我的代码:

  response = session.client("ec2").describe_images(
Filters=[
  {'Name': 'is-public',
   'Values': [False],
  },

当它仅接受字符串时,如何传递布尔过滤器?

谢谢...比尔

这对我有用...使用小写。

    ami_filter = [{"Name": "platform", 'Values': ["windows"]}, 
        {"Name": "virtualization-type", 'Values': ["hvm"]}, 
        {"Name": "image-type", 'Values': ["machine"]},
        {"Name": "architecture", 'Values': ["x86_64"]},
        {"Name": "state", 'Values': ["available"]},
        {"Name": "is-public", 'Values': ['false']}]

    ami_owners = ['amazon']
    results = client.describe_images(Filters=ami_filter, Owners=ami_owners)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM