在 python 中处理自定义列表类,例如
class ListData:
def __init__(self):
self.data = []
def add(self, x):
self.data.append(x)
def delete(self, x):
self.data.remove(x)
测试时,总是返回 None :
from list import ListData
listdata = ListData()
mylist = [34, 32, 34, 89]
mylist = listdata.add(2)
mylist = listdata.add(5)
print mylist # Prints None