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

如何解析非命令行输入的命令式文本?

  •  
  •   Candyhorse · Mar 21, 2013 · 4139 views
    This topic created in 4956 days ago, the information mentioned may be changed or developed.
    类似这样的命令:

    post search v2ex
    post search -a Livid
    ……

    不是从命令行输入,而是用户从网页端输入

    根据不同的命令,匹配不同的处理逻辑

    除了手工正则匹配外,有没有能够更方便地处理类似情况的模块?

    谢谢:)
    5 replies  •  1970-01-01 08:00:00 +08:00
    YUCOAT
        1
    YUCOAT  
       Mar 22, 2013 via Android
    不太明白你的意思
    undeflife
        2
    undeflife  
       Mar 22, 2013
    OptionParser
    hit9
        3
    hit9  
       Mar 22, 2013   ❤️ 1
    docopt 不错的。
    Candyhorse
        4
    Candyhorse  
    OP
       Mar 22, 2013
    @hit9

    very nice ~

    不知道 Python 自带的 argparser 能不能完成类似的任务?
    huangzxx
        5
    huangzxx  
       Mar 22, 2013
    argparser 是推荐用的,optparse 已经 deprecated
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4659 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 05:37 · PVG 13:37 · LAX 22:37 · JFK 01:37
    ♥ Do have faith in what you're doing.