我有这个:
with open('my_file', 'r') as f_in:
for i in f_in:
response = s3.head_bucket(Bucket='i')
print(response)
我希望为我的\文件中的那些bucket获取bucket属性,但是我得到:
botocore.exceptions.ClientError: An error occurred (403) when calling the HeadBucket operation: Forbidden
如果我只输入一个bucket名称,它也会失败
如果我硬编码bucket名称“(bucket='my-bucketoweiruowi')”,它就工作了!
如果我去掉for循环:
var = 'my-bucketoweiruow'
response = s3.head_bucket(Bucket='var')
。。。它失败了,出现了相同的403错误
我删除了“”如下所示:
with open('my_file', 'r') as f_in:
for i in f_in:
response = s3.head_bucket(Bucket=i)
print(response)
…但我还有一个错误:
botocore.exceptions.ClientError: An error occurred (400) when calling the HeadBucket operation: Bad Request".
我有两个单独的aws帐户,用于测试不同的bucket。同样的行为。你知道吗
看起来当进入循环时。。。打破?你知道吗
看起来在读取“我的\u文件”时,由于某种原因,跳转到下一行时,会在存储段名称之间添加一个空行。
这意味着如果我使用for循环打印内容,我将得到以下输出:
巴克1
巴克2
巴克3
所以,如果我去掉这些空行,事情会很顺利:
结论:当函数找到一个空行时,似乎发生了故障。你知道吗
相关问题 更多 >
编程相关推荐