实际上,当我display()
通过它调用方法时,obj2
它应该向我显示NULL
值。预期输出应该是Details Null Null Null Null Null
. 我该怎么做?
class Human:
def __init__(self, fname, mname, lname, age, gender):
self.fname = fname
self.mname = mname
self.lname = lname
self.age = age
self.gender = gender
def display(self):
print "Details", self.fname, self.mname, self.lname, self.age, self.gender
obj1 = Human('John','W','Cooper',23,'Male')
obj1.display()
obj2 = Human()
obj2.display()