self.fileobject.close()和self.fileobject.write()不好使

请问为什么跟着网课做的,self.fileObj.write写不进去文件呢,错误信息为'NoneType' object has no attribute 'write'。网课的人写的就好使,求解答

import time
class Mylog():
    # 属性
    fileurl = './'
    filename = str(time.strftime('%Y-%m-%d'))+'.log'
    fileObj = None
    # 方法
    def __int__(self):
        # 打开文件
        self.fileObj = open(self.fileurl+self.filename,'a+',encoding='utf-8')
    def wlog(self,s):
        #准备输入开始写入
        date = time.strftime('%Y-%m-%d %H:%M:%S')
        msg = date+' '+s
        # 写入
        print(msg)
        self.fileObj.write(msg)
    def __del__(self):
        #关闭打开的文件
        self.fileObj.close()
w = Mylog()
w.wlog('你好')

方法名错了


def __init__(self):
        # 打开文件
        self.fileObj = open(self.fileurl+self.filename,'a+',encoding='utf-8')
   

fileObj没有赋值

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632