Suds回复python SyntaxError:语法无效

时间:2017-03-21 16:18:40

标签: python api suds

我有一个泡沫回复。我使用result = Client.dict(results)将其格式化为dict对象。当我尝试访问部分结果(parts = result ['Product'] ['ProductPartArray'] ['ProductPart'])时,它会在内部控制台上给我一个语法错误。我不知道为什么会这样或者如何绕过它。代码运行正常,并给我我需要的结果,但它带我到一个语法错误的内部控制台。任何帮助?

Thanks
(reply){
   Product = 
      (Product){
         productId = "12"
         productName = "Pull-A-Part Key Tag"
         description[] = 
            "<ul><li>Printed Paper Inserts Are A Great Way To Customize At A Low Cost</li><li>Includes One Color Imprint On White Paper Background</li></ul>",
         ProductMarketingPointArray = 
            (ProductMarketingPointArray){
               ProductMarketingPoint[] = 
                  (ProductMarketingPoint){
                     pointType = "Highlight"
                     pointCopy = "Printed Paper Inserts Are A Great Way To Customize At A Low Cost"
                  },
                  (ProductMarketingPoint){
                     pointType = "Highlight"
                     pointCopy = "Includes One Color Imprint On White Paper Background"
                  },
            }
         export = True
         ProductCategoryArray = 
            (ProductCategoryArray){
               ProductCategory[] = 
                  (ProductCategory){
                     category = "Tools, Lights & Key Tags"
                     subCategory = "Metal - Bottle Opener / Key Tags"
                  },
            }
         ProductPartArray = 
            (ProductPartArray){
               ProductPart[] = 
                  (ProductPart){
                     partId = "0012SIL"
                     ColorArray = 
                        (ColorArray){
                           Color[] = 
                              (Color){
                                 colorName = "SILVER"
                              },
                        }
                     Dimension = 
                        (Dimension){
                           dimensionUom = "MM"
                           depth = 0.0
                           height = 3.5
                           width = 0.5
                           weightUom = "LB"
                           weight = 0.036
                        }
                     isRushService = True
                     ShippingPackageArray = 
                        (ShippingPackageArray){
                           ShippingPackage[] = 
                              (ShippingPackage){
                                 packageType = "Box"
                                 description = "EE"
                                 quantity = 500.0
                                 dimensionUom = "IN"
                                 depth = 13.0
                                 height = 11.0
                                 width = 13.0
                                 weightUom = "LB"
                                 weight = 24.0
                              },
                              (ShippingPackage){
                                 packageType = "Box"
                                 description = "E0"
                                 quantity = 1000.0
                                 dimensionUom = "IN"
                                 depth = 16.0
                                 height = 12.0
                                 width = 15.0
                                 weightUom = "LB"
                                 weight = 47.0
                              },
                              (ShippingPackage){
                                 packageType = "Box"
                                 description = "FA"
                                 quantity = 250.0
                                 dimensionUom = "IN"
                                 depth = 10.0
                                 height = 6.0
                                 width = 7.0
                                 weightUom = "LB"
                                 weight = 9.0
                              },
                        }
                     endDate = 2016-01-31 00:00:00
                     effectiveDate = 2016-01-01 00:00:00
                     isCloseout = False
                     isCaution = False
                     isOnDemand = False
                     isHazmat = False
                  },
            }
         lastChangeDate = 2016-01-01 00:00:00
         creationDate = 2016-01-01 00:00:00
         endDate = 2016-01-31 00:00:00
         effectiveDate = 2016-01-01 00:00:00
         isCaution = False
         isCloseout = False
         lineName = "HIT"
      }
 }
                    ^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "C:\Users\Justin Sumey\Anaconda2\lib\site-packages\qtconsole\base_frontend_mixin.py", line 163, in _dispatch
handler(msg)
File "C:\Users\Justin Sumey\Anaconda2\lib\site-packages\spyder\widgets\ipythonconsole\namespacebrowser.py", line 189, in _handle_execute_reply
self.handle_exec_method(msg)
File "C:\Users\Justin Sumey\Anaconda2\lib\site-packages\spyder\widgets\ipythonconsole\shell.py", line 244, in handle_exec_method
view = ast.literal_eval(data['text/plain'])
File "C:\Users\Justin Sumey\Anaconda2\lib\ast.py", line 49, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "C:\Users\Justin Sumey\Anaconda2\lib\ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 25
'view': Pull-A-Part Key Tag},
                  ^
SyntaxError: 
invalid syntax

1 个答案:

答案 0 :(得分:0)

product_name = str(结果[&#39;产品&#39;] [&#39; productName&#39;])我必须将str函数添加到name属性。