python boto3从s3 bucket中获取最后一个但只有一个修改过的对象
我有一个用例,我需要列出s3 bucket中最后一个但只有一个修改过的对象,该bucket在s3中有数百万个文件,下面使用boto3 s3客户端过滤是更好的方法吗?这是可行的方法还是最佳实践 这是我s3桶里的东西 s3://mybucket/dataset/date-20210304.txt->lastmodified 2021年3月4日 s3://mybucket/dataset/date-20210303.txt->lastmodified 2021年3月3日 s3://mybucket/dataset/date-20210302.txt->lastmodified 2021年3月2日 我需要取出这个对象->s3://mybucket/dataset/date-20210303.txt 我已经尝试了下面的代码python boto3从s3 bucket中获取最后一个但只有一个修改过的对象,python,amazon-web-services,amazon-s3,Python,Amazon Web Services,Amazon S3,我有一个用例,我需要列出s3 bucket中最后一个但只有一个修改过的对象,该bucket在s3中有数百万个文件,下面使用boto3 s3客户端过滤是更好的方法吗?这是可行的方法还是最佳实践 这是我s3桶里的东西 s3://mybucket/dataset/date-20210304.txt->lastmodified 2021年3月4日 s3://mybucket/dataset/date-20210303.txt->lastmodified 2021年3月3日 s3://mybucket/d
s3 = boto3.resource('s3')
my_bucket = s3.Bucket("myBucket")
files = my_bucket.objects.filter(Prefix = "dataset/date-")
files = [obj.key for obj in sorted(files, key=lambda x: x.last_modified,
reverse=True)]
print("files "+files[1])
我无法从这里打印上次修改的,我在这里做错了什么,有人能帮我吗?这应该可以解决问题