Python、"import gcsfs" 或 "from google.cloud import storage" 与 GCS 交互

For Python, "import gcsfs" or "from google.cloud import storage" to interact with GCS

我们理解的一些旧代码正在导入和使用这两个库。似乎两者都用于连接到 GCS 存储桶以及从存储桶读取/写入存储桶。

# GCS Library
import gcsfs # which of these...
from google.cloud import storage # ...is better?

是否维护了这两个库,或者 1 被认为是用于与 GCS 交互的更好的官方 python 库?

google-cloud-storage(您通过 from google.cloud import storage 导入)是 Google 在 their docs 中推荐的库。 同样,在该库的回购 readme 中说明:

The maintainers of this repository recommend using Cloud Client Libraries for Python, where possible, for new code development

您可以在其中找到 the repo for google-cloud-storage

另一方面,gcsfs's doc 指出:

This software is beta, use at your own risk.

似乎 google-cloud-* 库是推荐的官方方法。