Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 没有显示输出_Python 2.7 - Fatal编程技术网

Python 2.7 没有显示输出

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() 您应

我的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()

您应该打印以下值:

print (test.displayName())

这将输出值。

您没有打印任何内容。您正在检索一个值,但没有打印出来。请使用“打印”=>print test.displayName