class MyDef(object):
def __init__(self):
self.boxList = []
def appendListAndPrint(self,num):
self.boxList.append(num)
print(self.boxList[0])
for item in range(5):
myDef = MyDef()
print (myDef.appendListAndPrint(item))
输出结果
0
None
1
None
2
None
3
None
4
None
总结
没有return语句的函数或者方法,它的返回值是None