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

关于对字符串进行 strip,一个奇怪的原因

  •  
  •   RicardoScofileld · Jul 3, 2018 · 2525 views
    This topic created in 2898 days ago, the information mentioned may be changed or developed.

    就是对一条字符串进行 strip 操作,没有效果,但是用 replace 就可以生效,不知道大家有没有遇到这种情况。刚我又试了一下,貌似是 json 字符串进行 strip 就没有效果

    ofooo
        1
    ofooo  
       Jul 3, 2018
    卧槽我也是。。。。为什么啊
    RicardoScofileld
        2
    RicardoScofileld  
    OP
       Jul 3, 2018
    @ofooo 我特么研究半天,split,startswith 等操作都有效果,就是 strip 没有效果,按理来说 json_str 也算 str 类型的啊,我自省也是 str 类型的,但特么为什么就是没有效果啊
    samirmw
        3
    samirmw  
       Jul 3, 2018 via Android
    贴字符串上来看看啊
    dengshuang
        4
    dengshuang  
       Jul 3, 2018
    str(json)
    RicardoScofileld
        5
    RicardoScofileld  
    OP
       Jul 4, 2018
    @ofooo strip 只能去除最边上的字符,是我理解错了
    laike9m
        6
    laike9m  
       Jul 4, 2018 via Android
    给个例子?以及期望输出结果
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1141 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 23:06 · PVG 07:06 · LAX 16:06 · JFK 19:06
    ♥ Do have faith in what you're doing.