1

According to https://jcastellssala.com/2012/07/20/python-command-line-waiting-feedback-and-some-background-on-why/, '\r\x1b[K' is an escaping sequence that erases the current line in the console and rewrites something in Python. But when I tried to use the sequence on Windows cmd, it prints out weird characters instead. In Python, is there an equivalent sequence/action on Windows cmd where I can erase the last line I print out to the console?

chewong
  • 13
  • 3
  • please, see [this](https://stackoverflow.com/questions/8358533/python-module-to-enable-ansi-colors-for-stdout-on-windows) (packages: colorama, ansiterm, there are IMHO other) – RandomB Jan 12 '18 at 22:01

1 Answers1

2

Amazingly, support for ANSI escape sequences in the Windows console was only added in Windows 10 Version 1511:

http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-(v1511)-Console-Host-Enhancements

They will not work in older versions of Windows, unless you use a terminal emulator which supports them, like ConEmu:

https://conemu.github.io/

jbch
  • 591
  • 2
  • 6