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

python 初学者提问

  •  
  •   insaneDream · Aug 4, 2014 · 3171 views
    This topic created in 4312 days ago, the information mentioned may be changed or developed.
    def checkio(text):
    t_count = 0
    t_value = ''
    text_lower = text.lower()
    list = sorted(text_lower)
    for i in list:
    if i >= 'a' and i <= 'z':
    if text.count(i) > t_count:
    t_count=text.count(i)
    t_value=i


    print t_value

    checkio("Aaaooo") #打印的是o
    checkio("aaaooo") #打印的是a

    为什么会出现这个情况,
    text_lower = text.lower() 不是已经将所有的字符转为小写了吗?
    4 replies    2014-08-04 20:48:41 +08:00
    flyee
        1
    flyee  
       Aug 4, 2014
    t_count=text.count(i) <==== text -> text_lower
    insaneDream
        2
    insaneDream  
    OP
       Aug 4, 2014
    @flyee 可以细说一下吗 不太明白什么意思
    kamushin
        3
    kamushin  
       Aug 4, 2014   ❤️ 1
    @makubx1
    if i >= 'a' and i <= 'z':
    if text.count(i) > t_count:
    t_count=text.count(i)

    这三句用的不还是没lower时候的text吗。。
    insaneDream
        4
    insaneDream  
    OP
       Aug 4, 2014
    @kamushin 秒懂 感谢感谢!!! 原来自己瞎狗眼了 TAT
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3515 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 11:14 · PVG 19:14 · LAX 04:14 · JFK 07:14
    ♥ Do have faith in what you're doing.