boto3: TypeError: unsupported operand type(s) for |: 'str' and 'str'
boto3: TypeError: unsupported operand type(s) for |: 'str' and 'str'
我尝试按照 http://boto3.readthedocs.io/ 网页的说明测试 boto3 库。我尝试获取 Cloudformation 堆栈列表。所以我的代码是:
import boto3
client = boto3.client('cloudformation')
response = client.list_stacks(
NextToken='string',
StackStatusFilter=[
'CREATE_IN_PROGRESS'|'CREATE_FAILED'|'CREATE_COMPLETE'|'ROLLBACK_IN_PROGRESS'|'ROLLBACK_FAILED'|'ROLLBACK_COMPLETE'|'DELETE_IN_PROGRESS'|'DELETE_FAILED'|'DELETE_COMPLETE'|'UPDATE_IN_PROGRESS'|'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS'|'UPDATE_COMPLETE'|'UPDATE_ROLLBACK_IN_PROGRESS'|'UPDATE_ROLLBACK_FAILED'|'UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS'|'UPDATE_ROLLBACK_COMPLETE'|'REVIEW_IN_PROGRESS',
]
)
print response
当我 运行 执行此操作时,我收到如下错误消息:
TypeError: unsupported operand type(s) for |: 'str' and 'str'
有什么问题吗?我正在使用 Python 2.7
您在不应该的情况下包含了竖线符号 (|
)。他们在 boto3 文档中为您提供的语法只是向您展示了所有可能的过滤条件。您需要用逗号而不是竖线分隔可能的状态。或者,如果你想要 all cloudformation 堆栈,你可以省略 StackStatusFilter
参数
我尝试按照 http://boto3.readthedocs.io/ 网页的说明测试 boto3 库。我尝试获取 Cloudformation 堆栈列表。所以我的代码是:
import boto3
client = boto3.client('cloudformation')
response = client.list_stacks(
NextToken='string',
StackStatusFilter=[
'CREATE_IN_PROGRESS'|'CREATE_FAILED'|'CREATE_COMPLETE'|'ROLLBACK_IN_PROGRESS'|'ROLLBACK_FAILED'|'ROLLBACK_COMPLETE'|'DELETE_IN_PROGRESS'|'DELETE_FAILED'|'DELETE_COMPLETE'|'UPDATE_IN_PROGRESS'|'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS'|'UPDATE_COMPLETE'|'UPDATE_ROLLBACK_IN_PROGRESS'|'UPDATE_ROLLBACK_FAILED'|'UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS'|'UPDATE_ROLLBACK_COMPLETE'|'REVIEW_IN_PROGRESS',
]
)
print response
当我 运行 执行此操作时,我收到如下错误消息:
TypeError: unsupported operand type(s) for |: 'str' and 'str'
有什么问题吗?我正在使用 Python 2.7
您在不应该的情况下包含了竖线符号 (|
)。他们在 boto3 文档中为您提供的语法只是向您展示了所有可能的过滤条件。您需要用逗号而不是竖线分隔可能的状态。或者,如果你想要 all cloudformation 堆栈,你可以省略 StackStatusFilter
参数