Skip to main content
 首页 » 编程设计

python之在 python 3 中使用 boto

2025年05月04日8kerrycode

我有 boto 2.3.0 neo 分支和 python 3.3。 我使用 boto 从 simpledb 收集数据并且工作正常。 但是现在当我尝试 boto 连接到 s3 时出现错误。谁能指导我正确的方向。我真的不想降级我的 python,因为我的整个项目都在 python 3.3 中。

这是我写的命令列表:

       >>> from boto.s3.key import Key 
       >>> k = Key(bucket) 
       >>> k.key='testfile' 
       >>> k.set_contents_from_string('Hello this is my Boto S3 Test') 

这是我在执行最后一条命令时遇到的错误列表:

       Traceback (most recent call last): 
       File "<pyshell#8>", line 1, in <module> 
       k.set_contents_from_string('Hello this is my Boto S3 Test') 
       File "C:\Python33\lib\site-packages\boto\s3\key.py", line 1060, in               
       set_contents_from_string 
       fp = compat.StringIO(s) 
       TypeError: initial_value must be str or None, not bytes 

我一直遇到的其他问题(我猜 root 是一样的)在这个链接中给出:

iter() returned non-iterator of type 'Key' : boto amazon s3

请您参考如下方法:

实际上 boto 可以在 Python 3 中运行。

设置: