Created
March 20, 2018 09:17
-
-
Save Loveforkeeps/969036a4ac9d0784d3386170fce031a2 to your computer and use it in GitHub Desktop.
python lambda 实现switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 根据IP和PORT的csv文件,生成URL | |
def targetUrl(filename): | |
urllist = list() | |
with open(filename,"rU") as f: | |
reader = csv.DictReader(f) | |
for row in reader: | |
geturl = { | |
'443': lambda :"https://{}".format(row['IP']), | |
'8080': lambda :"http://{}:{}".format(row['IP'],row["PORT"]), | |
'80': lambda :"http://{}".format(row['IP']) | |
}[row["PORT"]] | |
urllist.append(geturl()) | |
return urllist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment