所用で必要になったので
# -*- coding: utf-8 -*-
import boto3
PUBLIC_S3_BUCKET_NAME_TEST = 'バケット名'
def access_count():
count = 0
with open('file.txt', 'w') as f:
# バケットの一覧取得
S3 = boto3.resource('s3')
S3BUCKET = S3.Bucket(PUBLIC_S3_BUCKET_NAME_TEST)
for obj in S3BUCKET.objects.all():
if '検索名' in obj.key:
count += 1
print(count, obj.key, obj.last_modified, file=f)
print('total=' + str(count), file=f)