How can I access s3 files in Python using urls?

后端 未结 6 1194
一个人的身影
一个人的身影 2020-12-14 16:44

I want to write a Python script that will read and write files from s3 using their url\'s, eg:\'s3:/mybucket/file\'. It would need to run locally and in the cloud without a

6条回答
  •  余生分开走
    2020-12-14 17:12

    Try s3fs

    First example on the docs:

    >>> import s3fs
    >>> fs = s3fs.S3FileSystem(anon=True)
    >>> fs.ls('my-bucket')
    ['my-file.txt']
    >>> with fs.open('my-bucket/my-file.txt', 'rb') as f:
    ...     print(f.read())
    b'Hello, world'
    

提交回复
热议问题