要查找S3中路径中间包含固定字符串的对象,可以使用以下代码示例:
import boto3
bucket_name = 'my-bucket' folder_path = 'path/to/fixed/string/'
s3 = boto3.client('s3')
response = s3.list_objects_v2( Bucket=bucket_name, Prefix=folder_path )
for obj in response['Contents']: if 'fixed-string' in obj['Key']: print(obj['Key'])
这将列出位于指定路径下,包含固定字符串的所有对象的名称。