列表、元组、字典是python中重要的三个数据类型(我是这么认为的),一个一个来吧
列表(list):可以在列表中添加、删除、修改元素
>>>namelist = ["Tom","Jhon","Smith"] //长度为3个元素
>>>print namelist
["Tom","Jhon","Smith"]
----------------------------------------------------------------------------
>>>namelist.append("Linda") //在namelist追加元素到末尾
>>>print namelist
["Tom","Jhon","Smith","Linda"]
--------------------------------------------------------------------------------------
>>>namelist.pop() //删除namelist末尾的元素
"Linda"
>>>print namelist
["Tom","Jhon","Smith"]
>>>namelist.pop(1) //删除列表指定位置的元素,列表索引从0开始,若是-1表示逆向索引,从-1开始
'Jhon'
>>>print namelist
["Tom","Smith"]
-----------------------------------------------------
>>>classlist = ["one","two"]
>>>namelist = ["Linda","Tom",classlist,"Jhon"] //相当于包含一个列表的二维列表
>>>print namelist
["Linda","Tom",["one","two"],"Jhon"]
学习自廖雪峰官网:http://www.liaoxuefeng.com/