推荐学习书目
› 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
013231
V2EX  ›  Python

你們寫Python代碼時是否使用`try...except...else...`結構?

  •  
  •   013231 · Feb 24, 2013 · 4837 views
    This topic created in 5005 days ago, the information mentioned may be changed or developed.
    我從來沒用過, 不過今天發現文檔中說

    "The use of the else clause is better than adding additional code to the try clause because it avoids accidentally catching an exception that wasn’t raised by the code being protected by the try ... except statement."

    http://docs.python.org/2/tutorial/errors.html

    但我仍然覺得多出個else clause不太方便, 並決定繼續不用.
    5 replies  •  1970-01-01 08:00:00 +08:00
    for4
    for4
    Feb 24, 2013❤️1
    1
    没用过
    for ... else ... 很好用
    keakon
    keakon
    Feb 24, 2013
    2
    mikale
    mikale
    Feb 24, 2013❤️1
    3
    如果你用python的时候,会去用N个elif,就不会使用到这个功能

    如果你使用dict来代替switch结构,就会使用到
    SharkIng
    SharkIng
    Feb 25, 2013
    5
    没有用过这个结构
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4411 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 03:28 · PVG 11:28 · LAX 19:28 · JFK 22:28
    ♥ Do have faith in what you're doing.