当允许用户在运行tim时选择方法时,无法在Suds中提取方法名称

2024-09-30 06:27:47 发布

您现在位置:Python中文网/ 问答频道 /正文

from suds.client import Client

from suds.transport.https import HttpAuthenticated

import urllib2

class methodinvokeclass():

    def methodinvokemethod(self,*args):

        method=args[1]         

        c=args[2]

        #method=LatLonListZipCode in the variable above
        response=c.service.method("90210")--How should I make this work ?

        #response=c.service.LatLonListZipCode("90210")
        #The above snippet works, but this not what I want
        #As I want to make it generic "method" and ask user in the run time to select     ---       #methodname

Tags: thetoinfromimportmakeresponseservice
1条回答
网友
1楼 · 发布于 2024-09-30 06:27:47
#method constains a string (eg: 'LatLonListZipCode')
method_to_call = getattr(c.service, method)
response = method_to_call("90210")

另外,你必须做一些错误检查以防找不到方法。在

相关问题 更多 >

    热门问题