See*_*r90 1 python dictionary amazon-s3 pickle amazon-web-services
我有一个 python 字典。我想将它保存为 AWS S3 中的泡菜对象。
我正在尝试这个 -
import boto3
import pickle
#Connect to S3 default profile
s3 = boto3.client('s3')
serializedMyData = pickle.dumps(myDictionary)
s3.put_object(Bucket='mytestbucket',Key='myDictionary')
Run Code Online (Sandbox Code Playgroud)
脚本成功运行,我在 S3 中得到一个名为 * myDictionary* 的文件。但它不是泡菜,它有 0 个字节。
我稍微编辑了我的代码 -
import boto3
import pickle
#Connect to S3 default profile
s3 = boto3.client('s3')
serializedMyData = pickle.dumps(myDictionary)
s3.put_object(Bucket='mytestbucket',Key='myDictionary').put(Body=serializedMyData)
Run Code Online (Sandbox Code Playgroud)
但是后来我收到了这个错误 -
AttributeError: 'dict' object has no attribute 'put'
Run Code Online (Sandbox Code Playgroud)
我该怎么办 ?
尝试 s3.put_object(Bucket='mytestbucket',Key='myDictionary', Body=serializedMyData)
请参阅https://docs.aws.amazon.com/code-samples/latest/catalog/python-s3-put_object.py.html
归档时间: |
|
查看次数: |
2582 次 |
最近记录: |