对象不可调用错误

时间:2017-12-02 03:36:23

标签: class object

import math

class Word:
    '''A class that represents word'''

def __init__(self, word):
    self._word = word

def __str__(self):
    return self._word


c = word("Hello")
print (c())

结果为“builtins.TypeError:'Word'对象不可调用”

如何使用print(c())检查c的值?

0 个答案:

没有答案