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

如何使用 Python 写出交互式的命令行程序

  •  
  •   caizixian ·
    caizixian · 2015-04-12 18:07:07 +08:00 · 2878 次点击
    这是一个创建于 3302 天前的主题,其中的信息可能已经有所发展或是发生改变。
    就像fdisk之类的一样
    有旧帖提到这个问题 /t/99667
    不过貌似没有很好的答案。
    不知到有没有什么方法/库能够做到这一点(最好支持tab补全)

    目前能想到的一种方式就是input('>')然后自己读进来,但是感觉很不优雅,也不支持补全
    5 条回复    2015-04-15 11:48:11 +08:00
    cbsw
        1
    cbsw  
       2015-04-12 18:29:38 +08:00
    http://pymotw.com/2/cmd/ 里面提到有 tab 补全
    swordfeng
        2
    swordfeng  
       2015-04-12 18:39:33 +08:00 via Android   ❤️ 1
    curses?
    wenLiangcan
        3
    wenLiangcan  
       2015-04-12 19:29:29 +08:00
    Library for building powerful interactive command lines in Python:

    https://github.com/jonathanslenders/python-prompt-toolkit
    caizixian
        4
    caizixian  
    OP
       2015-04-12 19:36:42 +08:00
    wuyu1998
        5
    wuyu1998  
       2015-04-15 11:48:11 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2880 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 11:36 · PVG 19:36 · LAX 04:36 · JFK 07:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.