首页 > 编程语言 > 详细

【python】 针对list的for循环

时间:2020-04-22 15:42:14      阅读:66      评论:0      收藏:0      [点我收藏+]

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

 

          

【python】 针对list的for循环

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!