变量函数:意思就是将函数名存在变量中,然后根据变量值动态的调用需要的函数。
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()