我一直在S3桶"测试"中关注JSON
{
'Details' : "Something"
}
Run Code Online (Sandbox Code Playgroud)
我使用以下代码来读取此JSON并打印"详细信息"键
s3 = boto3.resource('s3',
aws_access_key_id=<access_key>,
aws_secret_access_key=<secret_key>
)
content_object = s3.Object('test', 'sample_json.txt')
file_content = content_object.get()['Body'].read().decode('utf-8')
json_content = json.loads(repr(file_content))
print(json_content['Details'])
Run Code Online (Sandbox Code Playgroud)
我收到错误,因为'字符串索引必须是整数' 我不想从S3下载文件,然后阅读..