小编Swa*_*kar的帖子

如何从谷歌云存储桶中读取Python代码中的.json文件

我正在尝试从存储在谷歌云存储桶中的VM实例读取Python代码中的.json文件。dict()

我尝试将 json 文件读取为 blob:

client = storage.Client()
bucket = client.get_bucket('bucket-id-here')
blob = bucket.get_blob('remote/path/to/file.json')
str_json = blob.download_as_string()
Run Code Online (Sandbox Code Playgroud)

但我无法解码str_json. 我的做法正确吗?如果有任何其他方法可用,请告诉我。

我需要类似的东西:

client = storage.Client()
bucket = client.get_bucket('bucket-id-here')
blob = bucket.get_blob('remote/path/to/file.json')
str_json = blob.download_as_string()
Run Code Online (Sandbox Code Playgroud)

json python-3.x google-cloud-storage

14
推荐指数
2
解决办法
3万
查看次数

标签 统计

google-cloud-storage ×1

json ×1

python-3.x ×1