【发布时间】:2017-05-12 06:31:54
【问题描述】:
lambda 中的代码:
import boto3
def lambda_handler(event, context):
s3_client = boto3.resource('s3')
mybucket = s3_client.Bucket('bucket-name')
for object in mybucket.objects.all():
print(object)
for key in s3_client.list_objects(Bucket='bucket-name')['Contents']:
print(key['Key'])'
第一个“for”块列出存储桶中的所有键,但第二个“for”块引发以下错误。
's3.Service Resource' object has no attribute 'list_objects' : AttributeError
基于 http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.list_buckets 没有意义。关于可能是什么问题的任何提示?我使用了 python 2.7 和 python 3.6
【问题讨论】:
标签: python amazon-web-services amazon-s3 aws-lambda boto3