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

请问这个计算 1 到 100 之和的代码为什么会报错?

  •  
  •   Kung815 · Jul 25, 2017 · 2352 views
    This topic created in 3352 days ago, the information mentioned may be changed or developed.

    如图 http://wx2.sinaimg.cn/mw690/7f924972gy1fhw5ilojn4j20r8086aa2.jpg

    如果将 print 缩进, 就会返回一系列和, 所以请问如何使其只返回 5050。

    2 replies  •  2017-07-27 11:34:20 +08:00
    bubuyu
        1
    bubuyu  
       Jul 25, 2017
    for 那里不该有 number()
    sum=sum+x 下面直接按回车,print 前面 不该有...
    5oiR5piv5YK76YC8
        2
    5oiR5piv5YK76YC8  
       Jul 27, 2017
    确实有点问题,ipyhton 就可以,有点怪。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4927 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 06:00 · PVG 14:00 · LAX 23:00 · JFK 02:00
    ♥ Do have faith in what you're doing.