首页 > 编程语言 > 详细

python中,向 list 添加数据及几种方法

时间:2020-12-24 12:00:12      阅读:44      评论:0      收藏:0      [点我收藏+]

原文:https://blog.csdn.net/register_2/article/details/83387137

//...1...
def a():
    list=[]
    for i in range(1000):
        list=list+[i]
    print(list)
 
//...2...
def b():
    list=[]
    for i in range(1000):
        list+=[i]
    print(list)
 
//...3...
def c():
    list=[]
    for i in range(1000):
        list.append([i])
    print(list)
 
//...4...
def d():
    list=[i for i in range(1000)]
    print(list)
 
 
//...5...
def e():
    list(range(1000))
    print(list)

  

python中,向 list 添加数据及几种方法

原文:https://www.cnblogs.com/yeu4h3uh2/p/14182533.html

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