suzy

针对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])

 

          

分类:

技术点:

相关文章:

  • 2021-07-31
  • 2021-11-04
  • 2021-11-04
  • 2021-11-04
  • 2021-12-05
  • 2021-11-04
  • 2021-11-04
  • 2021-11-04
猜你喜欢
  • 2021-12-29
  • 2021-11-14
  • 2021-12-15
  • 2021-12-15
  • 2021-11-04
  • 2021-12-05
  • 2021-12-15
相关资源
相似解决方案