【发布时间】:2021-11-20 19:39:39
【问题描述】:
我正在编写一个 python 脚本来检索 AWS 的信息并且我试图只获取 SSEAlgorith 但我得到 TypeError: list indices must be integers or slices, not str 有没有办法做到这一点?我猜是为了 [] 里面的规则。
{
"ServerSideEncryptionConfiguration": {
"Rules": [
{
"ApplyServerSideEncryptionByDefault": {
"SSEAlgorithm": "AES256"
}
}
]
}
}
这是我用来检索信息的代码:
s3 = boto3.client('s3')
buc = s3.list_buckets()
for i in response['Buckets']:
enc = s3.get_bucket_encryption(Bucket=i['Name'])
rules = enc['ServerSideEncryptionConfiguration']['Rules']['ApplyServerSideEncryptionByDefault']['SSEAlgorithm']
print(rules)
【问题讨论】:
标签: python-3.x amazon-s3 boto3 boto botocore