1.列表生成式,迭代器&生成器 列表生成式 将列表[0,1,2,3,4,5,6,7,8]中的每个值加1,如何实现?常用的几种方法 方法一: a=[0,1,2,3,4,5,6,7,8] for i in a: a[i] +=1 b=a print(b) a=[0,1,2,3,4,5,6,7,8]b=[]for i in a:b.append(i+1)print(b) 方法二: a=[0,1,2,3,4,5,6,7,8] for index,i in enumerate(a): a[index] +…