我有一个list从文本文件附加到 a 的脚本。然后我使用''.join(mylist)转换为类型,str以便我可以查询DynamoDB表中的str. 这似乎工作,直到我查询表。我注意到我收到了空洞的回复。打印出每个 之后str,我注意到它们被垂直返回。如何正确格式化字符串以便我的调用DynamoDB成功?
import boto3
from boto3.dynamodb.conditions import Key, Attr
dynamo = boto3.resource('dynamodb')
table = dynamo.Table('mytable')
s3.Bucket('instances').download_file('MissingInstances.txt')
with open('MissingInstances.txt', 'r') as f:
for line in f:
missing_instances = []
missing_instances.append(line)
unscanned = ''.join(missing_instances)
for i in unscanned:
print(i)
response = table.query(KeyConditionExpression=Key('EC2').eq(i))
items = response['Items']
print(items)
Contents of MissingInstances.txt:
i-xxxxxx
i-yyyyyy
i-zzzzzz
etc etc
Output of print(i):
i
-
x
x
x
x
x
i
-
y
y
y
y
y
etc etc
的输出print(items):
[]
[]
[]
etc etc
期望的输出:
i-xxxxxx
i-yyyyyy
etc etc
慕尼黑5688855
喵喵时光机
相关分类