52
【25】Python生成器generator-只争朝夕-51CTO博客
source link: http://blog.51cto.com/000011211684/2069212
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
列表生成式一个小题目:将里列表[0,1,2,3]里面的数值都加1.方法1:a=[0,1,2,3]b=[]foriinrange(len(a)):b.append(i+1)a=bprint(a)方法2:a=[1,3,4,6,7,7,8]forindex,iinenumerate(a):a[index]+=1print(a)方法3:a=[0,1,2,3,4]a=map(lambdax:x+1,a)pr
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK