【python】 针对list的for循环

针对list的for循环两种方式,当时由于没搞懂range,导致使用了range(list1)错误方式,特此记录一下

  方法1    in直接读取list

1 list1 = ["abc","tello","hello","syou"]
2 
3 for i in list1:
4     print(i)

方法2  使用range

list1 = ["abc","tello","hello","syou"]

for i  in range(0,len(list1)):
     print(list[i])

          

原文地址:https://www.cnblogs.com/suzy/p/12752185.html