尝试使用boto3创建仪表板。如何在追加之前添加常量字符串,或者还有其他可用方法吗?
a = [1,2,3,4...]
我需要
[ "AWS/ElasticMapReduce", "MemoryAvailableMB", "JobFlowId", "1" ],
[ "AWS/ElasticMapReduce", "MemoryAvailableMB", "JobFlowId", "2" ],
[ "AWS/ElasticMapReduce", "MemoryAvailableMB", "JobFlowId", "3" ],
[ "AWS/ElasticMapReduce", "MemoryAvailableMB", "JobFlowId", "4" ]
我在做
a = [1,2,3]
x = []
for y in a:
x.append("AWS/ElasticMapReduce", "MemoryAvailableMB", "JobFlowId", "y")
print x
答案 0 :(得分:0)
您的代码可以像这样固定:
a = [1,2,3]
x = []
for y in a:
x.append(["AWS/ElasticMapReduce", "MemoryAvailableMB", "JobFlowId", y])
print (x)
请注意,这不会将a
中的原始整数转换为字符串...(在循环中使用str(y)
来做到这一点)