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

strip()疑问?

  •  
  •   explist · Jul 29, 2017 · 2478 views
    This topic created in 3349 days ago, the information mentioned may be changed or developed.

    print('abdpab sa'.strip('pab'))

    为什么结果是:'dpab s'

    3 replies  •  2017-08-09 21:30:21 +08:00
    virusdefender
        1
    virusdefender  
       Jul 29, 2017   ❤️ 3
    Return a copy of the string with leading and trailing characters removed. If chars is omitted or None, whitespace characters are removed. If given and not None, chars must be a string; the characters in the string will be stripped from the both ends of the string this method is called on.

    好好理解最后一句
    explist
        2
    explist  
    OP
       Jul 29, 2017
    原来如此,谢谢
    symons
        3
    symons  
       Aug 9, 2017
    1 Docstring for builtins:function strip
    2 ========================================
    3 S.strip([chars]) -> str
    4
    5 Return a copy of the string S with leading and trailing
    6 whitespace removed.
    7 If chars is given and not None, remove characters in chars instead.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2917 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 13:12 · PVG 21:12 · LAX 06:12 · JFK 09:12
    ♥ Do have faith in what you're doing.