[英]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.