Parsing Suds SOAP complex data type into Python dict

前端 未结 6 1831
生来不讨喜
生来不讨喜 2020-12-31 23:24

I have some data coming from a SOAP API using Suds which I need to parse in my Python script. Before I go off and write a parser (ther

6条回答
  •  情话喂你
    2020-12-31 23:37

    There is a class method called dict in suds.client.Client class which takes a sudsobject as input and returns a Python dict as output. Check it out here: Official Suds Documentation

    The resulting snippet becomes as elegant as this:

    from suds.client import Client
    
    # Code to obtain your suds_object here...
    
    required_dict = Client.dict(suds_object)
    

    You might also want to check out items class method (link) in the same class which extracts items from suds_object similar to items method on dict.

提交回复
热议问题