**COLUMN A** **COLUMN B**
[{TimePeriod: {Start: 2020-03-01
End: 2020-04-01}
我有一个从 AWS 提取数据的脚本。AWS 在运行此命令时会自动输入包含数据的信息。如何仅从 A 列中获取金额并使其看起来像 B 列?B 列是我的手动输入,A 列来自 AWS 输出。我可以向脚本中添加一些内容以仅输出金额吗?
替换:
results += data['ResultsByTime']
跟:
for info in data['ResultsByTime']:
for group in info['Groups']:
results.append(float(group['Metrics']['AmortizedCost']['Amount']))
如果您只想打印结果并包含链接帐户,请使用:
for info in data['ResultsByTime']:
for group in info['Groups']:
print(group['Keys'][0], group['Metrics']['AmortizedCost']['Amount'])
要同时显示日期:
for info in data['ResultsByTime']:
for group in info['Groups']:
print(group['Keys'][0], info['TimePeriod']['Start'], info['TimePeriod']['End'], group['Metrics']['AmortizedCost']['Amount'])