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

为什么输入结果是 None?

  •  
  •   Vegetables · Nov 12, 2018 · 2461 views
    This topic created in 2877 days ago, the information mentioned may be changed or developed.
    6 replies  •  2018-11-12 23:19:14 +08:00
    awah
        1
    awah  
       Nov 12, 2018 via Android
    递归 2//2 等于 0
    lifengming
        2
    lifengming  
       Nov 12, 2018   ❤️ 1
    递归调用时,else 那里没有用 return,丢失数据了
    ericls
        3
    ericls  
       Nov 12, 2018 via iPhone   ❤️ 1
    lifengming
        4
    lifengming  
       Nov 12, 2018   ❤️ 1
    还要一个问题,lz 你最后字符串应该是错了吧,取反是[::-1]
    Vegetables
        5
    Vegetables  
    OP
       Nov 12, 2018
    @lifengming 嗯 取反错了 else 里加上 return 我得再去看看递归该怎么写
    freemoon
        6
    freemoon  
       Nov 12, 2018   ❤️ 1
    a. [:-1] 你是想干嘛
    b. python 递归在调用的地方得带上 return,不然第一次出去的时候函数运行的结果就是 None,后面永远是 None。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4279 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 04:03 · PVG 12:03 · LAX 21:03 · JFK 00:03
    ♥ Do have faith in what you're doing.