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
Aliencn
V2EX  ›  Python

当 finally 遇上 continue 之 Python 版

  •  
  •   Aliencn · 2018-10-23 17:08:06 +08:00 · 2009 次点击
    这是一个创建于 2003 天前的主题,其中的信息可能已经有所发展或是发生改变。

    avatar

    图床有点慢

    你们猜这三个函数执行结果是什么?

    5 条回复    2018-10-24 10:03:14 +08:00
    AnyISalIn
        1
    AnyISalIn  
       2018-10-23 17:12:28 +08:00
    1. 返回 1
    2. print(0) -> print(1)
    3. 语法错误
    gnozix
        2
    gnozix  
       2018-10-23 17:21:30 +08:00
    《流畅的 Python 》你值得拥有
    wwqgtxx
        3
    wwqgtxx  
       2018-10-23 17:29:55 +08:00 via iPhone
    我记得 c()这种写法,专门有一个 pep 规范定义了是非法的语法
    GreatTony
        4
    GreatTony  
       2018-10-23 17:41:44 +08:00
    anywalker707
        5
    anywalker707  
       2018-10-24 10:03:14 +08:00
    return 就直接返回了,为什么还要 continue 和 break 呢?为什么凑 try …… finally 的工整吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5538 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:00 · PVG 14:00 · LAX 23:00 · JFK 02:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.