Python 2.7 没有显示输出
我的basic程序没有显示输出,请帮忙Python 2.7 没有显示输出,python-2.7,Python 2.7,我的basic程序没有显示输出,请帮忙 class className: def createName(self,name): self.name=name def displayName(self): return self.name if __name__ == '__main__': test=className() test.createName('John') test.displayName() 您应
class className:
def createName(self,name):
self.name=name
def displayName(self):
return self.name
if __name__ == '__main__':
test=className()
test.createName('John')
test.displayName()
您应该打印以下值:
print (test.displayName())
这将输出值。您没有打印任何内容。您正在检索一个值,但没有打印出来。请使用“打印”=>print test.displayName