我们正在理解的一些旧代码正在导入和使用这两个库。看起来两者都用于连接 GCS 存储桶以及从存储桶读取/写入存储桶。
# GCS Library
import gcsfs # which of these...
from google.cloud import storage # ...is better?
这两个库都得到维护,还是其中一个被认为是更好的、用于与 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-*
库是推荐的官方方式。
关于python - 对于Python, "import gcsfs"或 "from google.cloud import storage"与GCS交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68474003/