python 遍历列表三种方法
方法一:
list=[1,2,3]
for i in list:
print(list.index(i),i)
方法二:
list=[1,2,3]
for i in range(len(list)):
print(i,list[i])
方法三:
list=[1,2,3]
for i,v in enumerate(list):
print(i,v)
方法一:
list=[1,2,3]
for i in list:
print(list.index(i),i)
方法二:
list=[1,2,3]
for i in range(len(list)):
print(i,list[i])
方法三:
list=[1,2,3]
for i,v in enumerate(list):
print(i,v)