初始化
例: list = [123, 'abc']
查看某个元素
list[0]
增加元素
list += 'a'
删除元素
del list[0]
下面给出一个对象的例子
class test:
test_num = 0;
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
test.test_num += 1
def show_test_num(self):
print "num is %d" % test.test_num
def show_x_y(self):
print "x is %d and y is %d" %(self.x, self.y)
test1 = test(1, 2)
test2 = test(2, 3)
list = []
list+=[test1]
list+=[test2]
for i in list:
i.show_x_y()