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

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

  •  
  •   RicardoScofileld · 2018-07-03 17:09:06 +08:00 · 1758 次点击
    这是一个创建于 2116 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    ofooo
        1
    ofooo  
       2018-07-03 17:56:31 +08:00
    卧槽我也是。。。。为什么啊
    RicardoScofileld
        2
    RicardoScofileld  
    OP
       2018-07-03 18:06:27 +08:00
    @ofooo 我特么研究半天,split,startswith 等操作都有效果,就是 strip 没有效果,按理来说 json_str 也算 str 类型的啊,我自省也是 str 类型的,但特么为什么就是没有效果啊
    samirmw
        3
    samirmw  
       2018-07-03 19:52:25 +08:00 via Android
    贴字符串上来看看啊
    dengshuang
        4
    dengshuang  
       2018-07-03 21:13:35 +08:00
    str(json)
    RicardoScofileld
        5
    RicardoScofileld  
    OP
       2018-07-04 09:24:01 +08:00
    @ofooo strip 只能去除最边上的字符,是我理解错了
    laike9m
        6
    laike9m  
       2018-07-04 19:58:49 +08:00 via Android
    给个例子?以及期望输出结果
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5674 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 02:06 · PVG 10:06 · LAX 19:06 · JFK 22:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.