我想把下面的字典列表转换成字典
data=[
{
'code':'matata',
'commandes':[
{
'date':'12-10-22',
'content':[
{
'article':'Article1',
'designation':'Designe1',
'quantity':5
}
]
}
]
}
]我希望得到这个结果,这只是我们改变为{..}的起始括号
data={
{
'code':'matata',
'commandes':[
{
'date':'12-10-22',
'content':[
{
'article':'Article1',
'designation':'Designe1',
'quantity':5
}
]
}
]
}
}发布于 2022-11-16 10:04:27
相反,您可以使用列表和返回字典的第0次索引。
data = data[0]
print(data)
#output
data ={
'code':'matata',
'commandes':[
{
'date':'12-10-22',
'content':[
{
'article':'Article1',
'designation':'Designe1',
'quantity':5
}
]
}
]
}(更新1)如果您有多个骄傲:
for product in data:
print(product)(更新2)打印逗号:
for product in data:
print(product, end =",")https://stackoverflow.com/questions/74458417
复制相似问题