小编fac*_*ev7的帖子

使用 boto3 列出 S3 中带有后缀的对象

def get_latest_file_movement(**kwargs):
    get_last_modified = lambda obj: int(obj['LastModified'].strftime('%s'))
    s3 = boto3.client('s3')
    objs = s3.list_objects_v2(Bucket='my-bucket',Prefix='prefix')['Contents']
    last_added = [obj['Key'] for obj in sorted(objs, key=get_last_modified, reverse=True)][0]
    return last_added
Run Code Online (Sandbox Code Playgroud)

上面的代码为我提供了最新的文件,但我只想要以“csv”结尾的文件

python boto3

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

boto3 ×1

python ×1