【发布时间】:2021-02-10 13:12:22
【问题描述】:
我正在尝试从存储在谷歌云存储桶中的 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()
但我无法解码str_json。我的方法正确吗?如果有其他可用的方法,请告诉我。
我需要类似的东西:
# Method to load json
dict = load_json(gcs_path='gs://bucket_name/filename.json')
【问题讨论】:
标签: json python-3.x google-cloud-storage