python中的抽象方法

python中的抽象方法,python,python-3.x,Python,Python 3.x,根据教程,我期望从上面的代码中得到exption,但我得到的却是python的输出,这很奇怪,有人能解释一下为什么吗 产量 您正在使用Python3.x。在Python3.x中,声明语法的元类被更改 TypeError: Can't instantiate abstract class TryAbsMethod with abstract method set_val class SetTargeter(object,metaclass=abc.ABCMeta):#您使用的是哪本教程?@Eve

根据教程,我期望从上面的代码中得到exption,但我得到的却是python的输出,这很奇怪,有人能解释一下为什么吗

产量
您正在使用Python3.x。在Python3.x中,声明语法的元类被更改

TypeError: Can't instantiate abstract class TryAbsMethod with abstract method set_val

class SetTargeter(object,metaclass=abc.ABCMeta):#您使用的是哪本教程?@Evert:@RajeshChoudhary,请发布一个问题,而不是对不相关的答案进行评论。这是我的问题,请看这个
/usr/bin/python3.4 /home/murtuza/MyCodes/abstract.py
<__main__.TryAbsMethod object at 0x7f93ba8ab048>

Process finished with exit code 0
TypeError: Can't instantiate abstract class TryAbsMethod with abstract method set_val
class SetterGetter(object, metaclass=abc.ABCMeta):  # <---
    @abc.abstractmethod
    def set_val(self, inp):
        return

    @abc.abstractmethod
    def get_val(self):
        return