📜  处理 s3 异常 boto3 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:38.699000             🧑  作者: Mango

代码示例1
import boto3
from botocore.exceptions import ClientError

try:
    iam = boto3.client('iam')
    user = iam.create_user(UserName='fred')
    print("Created user: %s" % user)
except ClientError as e:
    if e.response['Error']['Code'] == 'EntityAlreadyExists':
        print("User already exists")
    else:
        print("Unexpected error: %s" % e)