创建_init_()方法

class Geese:
'''大雁类'''
def init(self):
print("我是大雁类!")
wildGoose = Geese()

运行上述代码,书中输出内容为
我是大雁类!

但我输出的是空白的,也没提示错误,是为什么


class Geese():
    def __init__(self,name):
        self.name=name
    def printinfo(self):
        print("我是:",self.name)
#创建a1对象
a1=Geese("大雁类")
a1.printinfo()

class Geese:
    '''大雁类'''
    def __init__(self):
        print("我是大雁类!")
wildGoose = Geese()

没有任何问题。是不是四个下划线漏了。

把你的代码按照代码的格式粘贴出来
你要问代码有什么问题,可是不按格式粘贴,下划线、空格全不见了,让人看什么

可以对比一下:

img