创建list
方式1 : 直接创建 theList = [1,2,3,4,5,6,7,8,9] ==> [1,2,3,4,5,6,7,8,9]
方式2 : 使用内建方法... 2 theList = list("abcdefg") ==> ["a","b","c","d","e","f","g"]
向list中增加元素
1 使用...List的append方法
theList = [] ; theList.append(1) ==> [1]
2 使用赋值的方法
theList = [] ; theList[0...:2] = [1,2] ==> [1,2]
在List中查找指定的元素
1 使用index方法,返回的是元素在list中的序号,如元素不在list中,会抛出ValueError异常
theList...= [1,2,3,4,5,6,7,8] ; indexNum = theList.index(1) ==> indexNum - 0
2 使用 in ,如果元素存在于List 中返回True