写一个类,给文件对象进行包装,确认在删除对象时能关闭文件
class File():
def __init__(self,filename='a')
self.new_file = open(filename,'r+')
def __del__(self):
self.new_file.close()
del self.new_file
标签:__,文件,python,self,file,new,时能
来源: https://blog.csdn.net/weixin_44756334/article/details/97677259