我在Python中具有以下AWS Lambda函数:
def lambda_handler(event, context):
# Code
# ..
# ..
# ..
# Code
output = ' '
for key in diff.keys():
for value in diff[key]:
output += "<br> Key: " + key + ", Value: " + value + "</br>"
print output
每次运行函数时,output
的值都会附加到上一次运行的值上,尽管它是用output = ' '
初始化的。
例如,如果output
的值是:
<br> Key: " + A + ", Value: " + 1 + "</br>
<br> Key: " + B + ", Value: " + 2 + "</br>
下次运行时,值将为:
<br> Key: " + A + ", Value: " + 1 + "</br>
<br> Key: " + A + ", Value: " + 1 + "</br>
<br> Key: " + B + ", Value: " + 2 + "</br>
<br> Key: " + B + ", Value: " + 2 + "</br>
在下一次运行时将是:
<br> Key: " + A + ", Value: " + 1 + "</br>
<br> Key: " + A + ", Value: " + 1 + "</br>
<br> Key: " + A + ", Value: " + 1 + "</br>
<br> Key: " + B + ", Value: " + 2 + "</br>
<br> Key: " + B + ", Value: " + 2 + "</br>
<br> Key: " + B + ", Value: " + 2 + "</br>
可能是什么问题?