这个Python列表里有哪些元素,你能告诉我吗?
- 内容介绍
- 文章标签
- 相关推荐
本文共计1286个文字,预计阅读时间需要6分钟。
9. 列表使用 + (1)append方法 + 说明:append(x)方法用于在列表末尾追加元素,参数x是插入元素的值。示例:[1, 2, 3].append(4)
9.列表的使用
(1)append方法
说明: append(x) append方法用于在列表的尾部追加元素,参数x是插入元素的值。
举例:
#coding:utf-8
test1 = [3,4,6,7,"Hello World"]
test1.append(3.9)
print test1 #reslut = [3, 4, 6, 7, 'Hello World', 3.8999999999999999]
(2)insert方法
说明: insert(index,value) insert方法用于在列表中插入元素。它有两个参数,index参数是索引位置,value参数是插入元素的值。
本文共计1286个文字,预计阅读时间需要6分钟。
9. 列表使用 + (1)append方法 + 说明:append(x)方法用于在列表末尾追加元素,参数x是插入元素的值。示例:[1, 2, 3].append(4)
9.列表的使用
(1)append方法
说明: append(x) append方法用于在列表的尾部追加元素,参数x是插入元素的值。
举例:
#coding:utf-8
test1 = [3,4,6,7,"Hello World"]
test1.append(3.9)
print test1 #reslut = [3, 4, 6, 7, 'Hello World', 3.8999999999999999]
(2)insert方法
说明: insert(index,value) insert方法用于在列表中插入元素。它有两个参数,index参数是索引位置,value参数是插入元素的值。

