Python 使用“我的循环”之外的列表将url字符串与一些列表值连接起来

Python 使用“我的循环”之外的列表将url字符串与一些列表值连接起来,python,amazon-sqs,Python,Amazon Sqs,我从sqs队列中收到3条消息:mapper.py、reducer.py和test.txt …并将每条消息存储在列表中 我想使用映射器、reducer和输入变量(最后3行代码)中每条消息的内容 但是在我的while循环之外,从我打印“连接到EMR”的那一行开始,我不知道如何使用我的文件名列表达到我想要的目的 你认为有什么解决办法吗 在我的print iteminside for循环中,它只显示filenames\u列表的第一个元素 conn = SQSConnection() myqueue =

我从sqs队列中收到3条消息:mapper.py、reducer.py和test.txt …并将每条消息存储在列表中

我想使用映射器、reducer和输入变量(最后3行代码)中每条消息的内容

但是在我的while循环之外,从我打印“连接到EMR”的那一行开始,我不知道如何使用我的文件名列表达到我想要的目的

你认为有什么解决办法吗

在我的
print item
inside for循环中,它只显示filenames\u列表的第一个元素

conn = SQSConnection()
myqueue = conn.get_queue('myQueue')
while myqueue.count() != 0:
    filenames_list = list()
    message = myqueue.read()

    myqueue.delete_message(message)
    filename = message.get_body()

    filenames_list.append(filename)


for item in files_list: 
    print item

print "Connecting to EMR"
conn = boto.emr.connect_to_region('us-east-1')
print "Creating Streaming step"
step = StreamingStep(name='Example1',

# after myFolder/ I want to put here the content of my list relative to test.txt

mapper="s3n://myFolder/HereIWantToPutTheListContentRelatedToMapper.py",  

# after myFolder/ I want to put here the content of my list relative to reducer.py

reducer="s3n://myFolder/HereIWantToPutTheListContentRelatedToReducer.py",   

# after myFolder/ I want to put here the content of my list relative to mapper.py 
input='s3n://myFolder/HereIWantToPutTheListContentRelatedToTest.txt',  

output='s3n://myFolder/output/wordcount_output')

您正在while\u循环的每次迭代开始时将文件列表初始化为空列表,因此您可能希望在列表之外对其进行初始化,并在while循环的每次迭代时将其追加到列表中?

谢谢!!不知道我怎么没看到。顺便说一句,现在我已经有了mapper、reducer和test.txt的列表,您知道在我的变量mapper、reducer和input中如何在每个变量中输入正确的列表值吗?抱歉,我不太确定那里使用了什么工具,所以显然没有任何实际经验了解它们对值的期望。如果您试图将文件列表中的正确值输入每个变量,您可能只想尝试在while循环中执行此操作,或者您想使用文件列表字典而不是列表,以便跟踪每个键对应的值。