cloudpathlib 简单试用
通过minio 作为s3 存储进行测试
s3 准备
- docker-compose
version: "3"
services:
s3:
image: minio/minio:latest
ports:
- 9000:9000
- 9001:9001
command: server /data --console-address ":9001"
使用
- 安装依赖
pip install cloudpathlib[s3]
- 代码集成
from cloudpathlib import S3Client,CloudPath
# 使用s3 client 配置minio 地址
client = S3Client(aws_access_key_id="minio", aws_secret_access_key="minio123",endpoint_url="http://localhost:9000")
cp1 = CloudPath("s3://demo/user01/demo.txt", client=client)
with cp1.open("w",) as f:
f.write("My new text!")
with cp1.open("r") as f:
print(f.read())
for cp in (cp0).glob("**/*.txt"):
print(cp)
- 效果
说明
以上只是简单得试用,实际上cloudpathlib 支持的标准pathlib 能力的同时还提供了不少其他功能,很值得尝试下
参考资料
https://github.com/drivendataorg/cloudpathlib
https://cloudpathlib.drivendata.org/
https://cloudpathlib.drivendata.org/stable/api-reference/cloudpath/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2022-10-29 dremio 23 版本 udf 可以使用了
2019-10-29 gtibase rpm包制作
2018-10-29 hasura 的3factor 架构结论
2018-10-29 citus real-time 分析demo( 来自官方文档)
2018-10-29 citus 多租户应用开发(来自官方文档)