使用python将数据写入Google云存储

使用python将数据写入Google云存储

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

问题描述

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

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

推荐答案

使用 google-cloud 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将数据写入Google云存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 21:19