Python继承错误

use*_*092 0 python

我想用显示功能打印self.row.但是,错误说明当类成员显然没有这样的self.row属性时.

请有人向我解释我做错了什么吗?

谢谢.

from Grid import Grid

class Matrix(Grid):
    def _init__(self, m, n, value=None):
        Grid.__init__(m, n)
        self.row = m
        self.col = n
    def display(self):
        print self.row
Run Code Online (Sandbox Code Playgroud)

kob*_*las 8

您在初始化呼叫中缺少"_".它应该是:

def __init__(self, m,n,value=None):
    ^
    +-- this character is missing.
Run Code Online (Sandbox Code Playgroud)