使用python将数据写入谷歌云存储 [英] Writing data to google cloud storage using python

查看:28
本文介绍了使用python将数据写入谷歌云存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到使用 python 将本地计算机中的数据集写入谷歌云存储的方法.我进行了很多研究,但没有找到任何关于此的线索.需要帮助,谢谢

I cannot find a way to to write a data set from my local machine into the google cloud storage using python. I have researched a a lot but didn't find any clue regarding this. Need help, thanks

推荐答案

快速示例,使用 谷歌云 Python库:

Quick example, using the google-cloud Python library:

from google.cloud import storage

def upload_blob(bucket_name, source_file_name, destination_blob_name):
  """Uploads a file to the bucket."""
  storage_client = storage.Client()
  bucket = storage_client.get_bucket(bucket_name)
  blob = bucket.blob(destination_blob_name)

  blob.upload_from_filename(source_file_name)

  print('File {} uploaded to {}.'.format(
      source_file_name,
      destination_blob_name))

更多示例在此 GitHub 存储库中:https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/storage/cloud-client

More examples are in this GitHub repo: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/storage/cloud-client

这篇关于使用python将数据写入谷歌云存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆