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

Python 和 Power shell 的字符串 Split 问题

  •  
  •   wittyfans · Dec 2, 2020 · 2140 views
    This topic created in 2123 days ago, the information mentioned may be changed or developed.

    今天用 Poweshell 提取字符串的时候发现一个小问题:

    "cell_20201403_20201407_CONDOM_24837_30_211SZH_000000J5X.csv".split(".csv")[0]

    这条代码在 Python 中和 Power shell 中是都可以运行的,但结果为什么不一样呢?

    powershell_vs_python

    3 replies  •  2020-12-02 23:33:00 +08:00
    wittyfans
        1
    wittyfans  
    OP
       Dec 2, 2020
    找到原因了,得这样写:

    ```
    "cell_20201403_20201407_CONDOM_24837_30_211SZH_000000J5X.csv" -split ".csv"
    ```

    参见: https://stackoverflow.com/a/22200431
    Lemeng
        2
    Lemeng  
       Dec 2, 2020
    自己能找到问题,印象更深刻
    wittyfans
        3
    wittyfans  
    OP
       Dec 2, 2020 via iPhone
    @Lemeng 对的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1011 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 18:29 · PVG 02:29 · LAX 11:29 · JFK 14:29
    ♥ Do have faith in what you're doing.