python对象销毁实例(垃圾回收)
作者:百世修行 时间:2022-07-29 06:22:14
我就废话不多说了,直接上代码吧!
'''python对象销毁(垃圾回收)'''
class Point:
'info class'
def __init__(self,x=0,y=0):
self.x = x
self.y = y
def __del__(self):
class_name = self.__class__.__name__
print(class_name, '销毁')
pt1 = Point()
pt2 = pt1
pt3 = pt2
print(id(pt1),id(pt2),id(pt3))
print(1)
del pt1
print(2)
del pt2
print(3)
del pt3
直到最后一个引用销毁
__del__ # 被调用
来源:https://blog.csdn.net/ccorg/article/details/79577014
标签:python,对象销毁,垃圾回收
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python 爬取英雄联盟皮肤并下载的示例
2023-07-22 09:57:45
![](https://img.aspxhome.com/file/2023/0/60970_0s.png)
golang的httpserver优雅重启方法详解
2023-08-06 00:22:41
也说说语义
2009-12-29 13:04:00
Python warning警告出现的原因及忽略方法
2021-10-16 10:59:02
从品牌网站看交互设计
2009-08-18 12:39:00
![](https://img.aspxhome.com/file/UploadPic/20098/18/1-31s.jpg)
有效LOGO设计的最重要的提示
2010-06-09 12:05:00
![](https://img.aspxhome.com/file/UploadPic/20106/9/01-95s.gif)
如何提高网页的维护效率
2009-03-01 11:33:00
Go获取与设置环境变量的方法详解
2023-06-21 04:35:10
Python3 mmap内存映射文件示例解析
2021-07-14 15:05:50
![](https://img.aspxhome.com/file/2023/1/66891_0s.png)
MySQL数据库管理必备工具 phpMyAdmin 3.0
2008-12-10 14:12:00
![](https://img.aspxhome.com/file/UploadPic/200812/20081212115238456.jpg)
php+ajax无刷新上传图片实例代码
2023-11-17 11:27:58
![](https://img.aspxhome.com/file/2023/1/104181_0s.png)
Access秘密技巧和陷阱
2008-04-12 14:55:00
详解Python中的数据清洗工具flashtext
2021-10-05 01:59:47
![](https://img.aspxhome.com/file/2023/5/69645_0s.png)
使用python刷访问量的示例代码
2023-11-09 12:55:30
Python产生一个数值范围内的不重复的随机数的实现方法
2023-09-19 21:48:09
Python爬虫之爬取二手房信息
2021-08-11 19:40:50
![](https://img.aspxhome.com/file/2023/9/68869_0s.jpg)
Python中列表list以及list与数组array的相互转换实现方法
2023-08-24 06:30:15
《写给大家看的设计书》阅读笔记之对齐原则
2009-07-09 16:32:00
![](https://img.aspxhome.com/file/UploadPic/20097/9/dq-25s.jpg)
Python unittest单元测试框架的使用
2021-11-26 15:56:37
SQL Server中链接服务器将替代远程服务器
2009-06-15 11:03:00