我需要从Dictionary对象中删除一个属性。我正试图用" del,"但它不适合我。
from suds.client import Client
from sys import argv
cmserver = '***my-server-host-name***'
cmport = '8443'
wsdl = 'file:///code/AXL/axlsqltoolkit/schema/10.5/AXLAPI.wsdl'
location = 'https://' + cmserver + ':' + cmport + '/axl/'
username = argv[1]
password = argv[2]
client = Client(url=wsdl,location=location, username=username, password=password)
result = client.service.getPhone(name='SEP64AE0CF74D0A')
del result['_uuid']
守则失败:
Traceback (most recent call last):
File "AXL-Get-Phone.py", line 27, in <module>
del result['_uuid']
AttributeError: __delitem__
我想要删除的对象的示例[print(str(result))
]输出&#39; _uuid&#39;从:
(reply){
return =
(return){
phone =
(RPhone){
_uuid = "{D1246CFA-E02D-0731-826F-4B043CD529F1}"
答案 0 :(得分:0)
首先,您需要将结果转换为dict
。有suds.client.Client
类方法dict
可以为您执行此操作。请参阅suds.client.Client的文档。
result = Client.dict(client.service.getPhone(name='SEP64AE0CF74D0A'))
del result['_uuid']
此外,您可以简单地删除_uuid
属性,例如:
result = client.service.getPhone(name='SEP64AE0CF74D0A')
del result._uuid