是否有 python 代码来查找 S3 存储桶中文件的长度

问题描述

下面是代码片段。感谢对此的投入

s3_resource = boto3.resource('s3')
object_file = s3_resource.Object(bucket_name=bucket_name,key=object_key)
file_size=object_file.content_length
print("Size of the file being processed:".format(file_size))

每次我尝试打印文件大小时,此代码代码都会打印空白输出

解决方法

改变

print("Size of the file being processed:".format(file_size))

print("Size of the file being processed: {}".format(file_size))