python _列表操作(一)

a=[”张三”, ”李四”,”王五”]

a1=(’赵六’,’黄七’)

a2=[”徐九”,”华十”]

 print(a[2])

输出结果:李四

*总结:输出列表第二个对象

 

添加

append() 方法

a.append(a1)

a.append(a2)

print(a)

输出:[‘张三’,’李四’,’王五’,( ‘赵六’,’黄七’),[ ‘徐九’,’华十’]]

*总结:append方法是直接将新添加的列表或元组(原定义格式(列表或者元组))按顺序添加到已定义的列表后面输出

 

exted()方法

a. extend(a1)

print(a)

输出: [‘张三’,’李四’,’王五’, ‘赵六’,’黄七’]

*总结:exted()方法是把每个数据添加到列表(不区分定义格式)

 

insert()方法

 列表.insert(位置,”对象”)

a. insert(1,”nb”)

print(a)

输出: [‘张三’,’nb’,’李四’,’王五’]

posted @ 2021-03-11 09:54  離落  阅读(89)  评论(0)    收藏  举报
{ "posted": "Dreamer-Paul", "version": "Live2DViewerEX Config 1.0", "model": "sagiri.moc", "textures": [ "textures/texture_00.png", "textures/texture_01.png" ], "layout": { "center_x": 0, "center_y": 0, "width": 2 }, "motions": { "tap": [ { "file": "motions/tap/c.mtn" } ], "idle": [ { "file": "motions/idle/idle_01.mtn" }, { "file": "motions/idle/idle_02.mtn" }, { "file": "motions/idle/idle_03.mtn" }, { "file": "motions/idle/idle_04.mtn" } ] }, "physics": "physics.json" }