V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
KyL
V2EX  ›  Python

Python Class 中的__del__和__exit__有什么区别?

  •  
  •   KyL · 2015-02-20 19:07:32 +08:00 · 6637 次点击
    这是一个创建于 3352 天前的主题,其中的信息可能已经有所发展或是发生改变。
    5 条回复    2015-02-21 07:42:47 +08:00
    Wicked
        1
    Wicked  
       2015-02-20 19:31:39 +08:00 via iPhone
    问google
    ryd994
        2
    ryd994  
       2015-02-20 19:51:51 +08:00
    RTFM
    neoblackcap
        3
    neoblackcap  
       2015-02-20 19:57:15 +08:00
    一个是你在delete对象时候调用的,一个是with语法,退出上下文的时候调用的,真的建议去读官方文档。
    ruoyu0088
        4
    ruoyu0088  
       2015-02-20 20:44:49 +08:00
    就是英语delete 和 exit 的区别。
    lcj2class
        5
    lcj2class  
       2015-02-21 07:42:47 +08:00 via Android
    这种问题为什么要在V2上出现,Google一下不比什么来的实在
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5669 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 121ms · UTC 06:07 · PVG 14:07 · LAX 23:07 · JFK 02:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.