我已经使用flask创建了web服务,所以添加了请求JSON参数,但现在的问题是如何将dict拆分为简单数据
我的字典是
order={
"userid":17,
"details":[
{
"productid":1,
"eachprice":45,
"quantity":1,
"price":45
},
{
"productid":3,
"eachprice":749,
"quantity":1,
"price":749
}
]
}
所以我就这样分手了
for x, y in order.items():
print(x, y)
但问题是如何打印嵌套数据
一个快速且不太好的解决方案是:
基于递归计算对象大小的方法,此递归解决方案基本上将整个数据结构展平为一维列表:
相关问题 更多 >
编程相关推荐