Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Suds Python数组响应_Python_Arrays_Object_Soap_Suds - Fatal编程技术网

Suds Python数组响应

Suds Python数组响应,python,arrays,object,soap,suds,Python,Arrays,Object,Soap,Suds,使用Python2.7和SUDS。如何仅打印这些数组/对象的URL?我希望能够选择任何数组/对象(例如URL),并只打印它们的整个列表,而不是/或除了服务器已经给出的响应之外 这是我的要求: from suds.client import Client import logging # Specify Login Information developer_key = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' password = 'xxxxxxxx'

使用Python2.7和SUDS。如何仅打印这些数组/对象的URL?我希望能够选择任何数组/对象(例如URL),并只打印它们的整个列表,而不是/或除了服务器已经给出的响应之外

这是我的要求:

from suds.client import Client
import logging



# Specify Login Information
developer_key = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
password = 'xxxxxxxx'
account_guid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'
sku = ['A30938', 'B84727']

# Specify URLs
wsdl_url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v6/InventoryService.asmx?WSDL'
service_url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v6/InventoryService.asmx'

# Initialize client.
client = Client(wsdl_url, location = service_url)

# Pass login information
login = client.factory.create('APICredentials')
login.DeveloperKey = developer_key
login.Password = password
client.set_options(soapheaders=login)

# Initiate request
for i in sku:

    result = client.service.GetInventoryItemImageList(account_guid, i)

    # Print the result to the screen.
    print result
结果如下:

(APIResultOfArrayOfImageInfoResponse){
   Status = "Success"
   MessageCode = 0
   ResultData = 
      (ArrayOfImageInfoResponse){
         ImageInfoResponse[] = 
            (ImageInfoResponse){
               PlacementName = "ITEMIMAGEURL1"
               FolderName = None
               Url = "d3t71aa9ase5oz.cloudfront.net/12801479/images/bear_white.jpg"
            },
            (ImageInfoResponse){
               PlacementName = "ITEMIMAGEURL2"
               FolderName = None
               Url = "d3t71aa9ase5oz.cloudfront.net/12801479/images/bear_black.jpg"
            },
      }
 }
(APIResultOfArrayOfImageInfoResponse){
   Status = "Success"
   MessageCode = 0
   ResultData = 
      (ArrayOfImageInfoResponse){
         ImageInfoResponse[] = 
            (ImageInfoResponse){
               PlacementName = "ITEMIMAGEURL1"
               FolderName = None
               Url = "http://d3t71aa9ase5oz.cloudfront.net/12801479/images/m89851.jpg"
            },
      }
 }

只需遍历这些项并获得所需的属性。比如:

for item in response:
    for data in item.ResultData:
        print data.Url

我得到:AttributeError:“tuple”对象没有属性“Url”