变量函数:意思就是将函数名存在变量中,然后根据变量值动态的调用需要的函数。

LOGIN = 'xxxx'
PASSWD = "xxx"
URL = 'xxxxx'

def handler_version(url):
    return url

def request_version(url):
    return req

for funcType in ('handler', 'request'):
    print '*** Using %s:' % funcType.lower()
    #a='%s_version'%funcType
    url = eval('%s_version'%funcType)(URL)###wval把string变量转换成相应函数
    #url = a(URL)
    print url
    f = urllib2.urlopen(url)
    print f.readline()
    f.close()

  

相关文章:

  • 2021-09-21
  • 2022-01-01
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-25
  • 2022-01-10
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案