python 【列表解析】

1 #列表解析
2 list1 = ['2','4','6','8']
3 
4 def g(x):
5     return(int(x)**2)
6 
7 list2= [g(x) for x in list1]
8 print(list2)

 

posted @ 2018-03-26 15:28  Justice-V  阅读(118)  评论(0)    收藏  举报