![](/img/trans.png)
[英]If you're opening a file using the 'with' statement, do you still need to close the file object?
[英]Do you need to close a key using boto?
在boto中使用S3键的所有示例都省略了close
方法,但我可以看到它在API中。 将文件写入密钥后,一个呼叫应该close
吗?还是没有必要? 即第3行是必要的:
key = s3.get_bucket(bucket_name).new_key(filename)
key.set_contents_from_string(data)
key.close()
Amazon S3没有“打开”或“关闭”文件的概念。 它要么(整体上)存在,要么不存在。
set_contents_from_string()
函数创建对象并存储数据。 该对象无法增量更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.