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

strip()疑问?

  •  
  •   explist · 2017-07-29 11:31:03 +08:00 · 1755 次点击
    这是一个创建于 2676 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    为什么结果是:'dpab s'

    3 条回复    2017-08-09 21:30:21 +08:00
    virusdefender
        1
    virusdefender  
       2017-07-29 11:36:46 +08:00   ❤️ 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
       2017-07-29 11:48:22 +08:00
    原来如此,谢谢
    symons
        3
    symons  
       2017-08-09 21:30:21 +08:00
    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.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2488 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:51 · PVG 23:51 · LAX 07:51 · JFK 10:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.