📜  在 boto3 中导入 NoSuchKey - Python 代码示例

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

代码示例1
from botocore.exceptions import ClientError

try:
    response = self.client.get_object(Bucket=bucket, Key=key)
    return json.loads(response["Body"].read())
except ClientError as ex:
    if ex.response['Error']['Code'] == 'NoSuchKey':
        logger.info('No object found - returning empty')
        return dict()
    else:
        raise