amazon-s3 - 使用 boto3 删除 AWS S3 存储桶 - AttributeError

标签 amazon-s3 aws-lambda boto3

我正在尝试使用 boto3 库删除 S3 存储桶

import boto3

s3 = boto3.client('s3')
bucket = s3.Bucket('my-bucket')
response = bucket.delete()

我收到以下错误:

"errorType": "AttributeError",
"errorMessage": "'S3' object has no attribute 'Bucket'"

我看不出有什么问题...谢谢

最佳答案

试试这个:

import boto3    
s3 = boto3.resource('s3')
bucket = s3.Bucket('my-bucket')
bucket.delete()

关于amazon-s3 - 使用 boto3 删除 AWS S3 存储桶 - AttributeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44281684/

相关文章:

amazon-s3 - 亚马逊 S3 : Can clients see the file before upload is complete

java - 在适用于 Java 的开发工具包中操作 AWS 基本 URL

java - 如何运行 amazon s3 中的 java jar 文件

php - 将使用 fopen 创建的文件上传到 AWS S3 存储桶

java - 如何从 Android 应用程序为 AWS Lambda 函数提供参数?

python - 如何从 key BlockDeviceMappings 获取 VolumeId(boto3 获取 ec2 的卷信息)

forms - 使用 AWS API Gateway 和 Lambda 从 multipart/form-data 获取非文件正文

amazon-web-services - 在 AWS LEX 中从一个意图调用另一个意图

python - 'S 3' object has no attribute ' 桶'

python 调用 boto3.client.create_data_source_from_s3