我正在使用 boto 从扫描中检索发电机元素。
for item in scan_results:
print item
我可以通过以下方式访问每个属性:
for item in scan_results:
print item['propA']
for item in scan_results:
print json.dumps(item) # This does not work
如何将每个项目转换为 json 对象或字典? 如果可以的话,我想避免遍历 item 中的键并通过循环生成字典。
最佳答案
这个怎么样?
对于 scan_results 中的项目:
打印 json.dumps(dict(item))
关于python - 如何将 dynamo 项目从 scan 转换为 dict/json?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29381661/