You can list all buckets using the list_buckets method. Here’s an example:
import boto3
s3 = boto3.client('s3')
# List buckets
response = s3.list_buckets()
# Print bucket names
for bucket in response['Buckets']:
print(bucket['Name'])
This script lists all buckets in your AWS account.