推荐学习书目
› 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 · Dec 8, 2013 via Android · 10136 views
    This topic created in 4675 days ago, the information mentioned may be changed or developed.
    就是清除当前行 在当前行上继续输出而不是清屏
    6 replies  •  1970-01-01 08:00:00 +08:00
    dndx
        1
    dndx  
       Dec 8, 2013
    TankyWoo
        2
    TankyWoo  
       Dec 8, 2013
    VYSE
        3
    VYSE  
       Dec 8, 2013
    sys.stdout.write不回车就是刷新当前行
    caizixian
        4
    caizixian  
    OP
       Dec 10, 2013 via Android
    @VYSE 不是太懂 能不能说详细些
    VYSE
        5
    VYSE  
       Dec 11, 2013
    @caizixian

    from time import sleep
    import sys

    for i in range(1000):
    sys.stdout.write(str(i)+'\r')
    sleep(0.1)
    VYSE
        6
    VYSE  
       Dec 11, 2013
    @caizixian 好吧说错了,\r是回车,只要别\n就不会到新一行了,\r回车就是回到行首的意思
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2929 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:07 · PVG 11:07 · LAX 20:07 · JFK 23:07
    ♥ Do have faith in what you're doing.