----------------list_create.py----------------------
list = ["apple", "banana", "grape", "orange"]
print list
print list[2]
list.append("watermelon")
list.insert(1, "grapefruit")
print list
list.remove("grape")
print list
print list.pop()
print list
list = ["apple", "banana", "grape", "orange"]
print list[-2]
print list[1:3]
print list[-3:-1]
list = [["apple", "banana"],["grape", "orange"],["watermelon"],["grapefruit"]]
for i in range(len(list)):
print "list[%d] :" % i, "" ,
for j in range(len(list[i])):
print list[i][j], "" ,
print
----------------list_use.py----------------------
list = ["grape", "grape"]
list2 = ["apple", list, "orange"]
print list
print list2
list3=[i for i in list1 if i not in list2]
----------------list_index_sort.py----------------------
list = ["apple", "grape", "grape", "orange"]
list.remove("grape")
print list
list = ["apple", "banana", "grape", "orange"]
print list.index("grape")
print list.index("orange")
print "orange" in list
list1 = ["apple", "banana"]
list2 = ["grape", "orange"]
list1.extend(list2)
print list1
list3 = ["watermelon"]
list1 = list1 + list3
print list1
list1 += ["grapefruit"]
print list1
list1 = ["apple", "banana"] * 2
print list1
list = ["banana", "apple", "orange", "grape"]
list.sort()
print "Sorted list:", list
list.reverse()
print "Reversed list:", list
list = ["banana", "apple", "orange", "grape"]
for li in sorted(set(list)):
print li, "" ,
-------------list_stack_sep.py(堆栈、队列)-----------------
list = ["apple", "banana", "grape"]
list.append("orange")
print list
print "弹出的元素:", list.pop()
print list
list = ["apple", "banana", "grape"]
list.append("orange")
print list
print "弹出的元素:", list.pop(0)
print list