迭代與列表推導

>>> a=[1,2,3] >>> for i, v in enumerate(a): ... print(i,":",v) ... 0 : 1 1 : 2 2 : 3 >>> b= (2,4,6) >>> for i,j in zip(a,b): ... print(i,";",j) ... 1 ; 2 2 ; 4 3 ; 6 >>> a=[1,2,3,4] >>> [2*i for i
相關文章
相關標籤/搜索