我有一份清单,上面有下列项目:
poly = ['AddTicketResponse.xsd', {
'OrderServiceType': 'stPickUp',
'Taxes': {'Tax': {'Caption2': None, 'Caption': 'Sales Tax IN',
'Amount': '1.26'}},
'CreditSubtotal': '0',
'Version': '1',
'NetSubtotal': '13.97',
'CreatedTime': '2018-08-14T19:19:13Z',
'PriceGroupName': '$$Regular Price Group$$',
'PurchaseSubtotal': '13.97',
'Status': 'tsOpen',
'ItemCount': '2',
'Seq': '105651',
'Warnings': {'Warning': {'Message': 'The customer name from SpeedLine Connect differs from the name in the customer record.'
}},
'PaymentTotal': '0',
'Agent': None,
'ID': '1678'
'TaxSubtotal': '1.26',
'MenuSelections': {'MenuSelection': [{
'MenuCalculatedPriceOfAggregatedSelections': '0',
'PLU': '44'
}]}
}]
这里有两个对象: 我是保利[1],这是:
{
'OrderServiceType': 'stPickUp',
'Taxes': {'Tax': {'Caption2': None, 'Caption': 'Sales Tax IN',
'Amount': '1.26'}},
'CreditSubtotal': '0',
'Version': '1',
'NetSubtotal': '13.97',
'CreatedTime': '2018-08-14T19:19:13Z',
'PriceGroupName': '$$Regular Price Group$$',
'PurchaseSubtotal': '13.97',
'Status': 'tsOpen',
'ItemCount': '2',
'Seq': '105651',
'Warnings': {'Warning': {'Message': 'The customer name from SpeedLine Connect differs from the name in the customer record.'
}},
'PaymentTotal': '0',
'Agent': None,
'ID': '1678'
'TaxSubtotal': '1.26',
'MenuSelections': {'MenuSelection': [{
'MenuCalculatedPriceOfAggregatedSelections': '0',
'PLU': '44'
}]}
}
作为一个单独的字典,这样我就可以得到“MenuSelections”的所有值 到目前为止,我只能将xml文件转换为列表并得到这些值。你知道吗
root = ElementTree.XML(pos_xml)
xmldict = XmlDictConfig(root)
poly=[]
for key, value in xmldict.iteritems():
poly.append(value)
老实说,任何建议都会有帮助。你知道吗
它将在
poly
列表的第二个位置提取对字典的引用,并将其存储在新名称d
。你知道吗你可以用它来得到你想要的
您也可以直接索引
poly[1]
:将打印
相关问题 更多 >
编程相关推荐