Unprint a line on the console in Python?

后端 未结 3 1751
难免孤独
难免孤独 2020-12-17 03:16

Is it possible to manipulate lines of text that have already been printed to the console?

For example,

import time
for k in range(1,100):
     print(         


        
3条回答
  •  臣服心动
    2020-12-17 03:47

    What you need are ANSI Command Codes. http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes
    You also need code to activate ANSI Command Codes. I would use Colorama. https://pypi.python.org/pypi/colorama

    OR

    Use curses (Python 3.4+) module.

提交回复
热议问题