Like when using aircrack-n开发者_Python百科g, or any program that has tables of data that constantly update.
=\
It depends somewhat on the system, and above all, how much you want to overwrite. For a lot of simply programs, outputting '\r'
will do the trick: it will return the cursor to the start of the line (on almost all consoles), and you can overwrite the line. (I've used this in the past for continuously updated progress reports: n records processed
, for example. Just be sure to not output a '\n'
until you're ready.
For anything more complex, the usual solution is the curses
library. It should be present on most Unix (sometimes under the name ncurses
), and there's a port of ncurses
to Windows as well. (The generic name of the library, and its name under traditional Unix, is curses
; ncurses
is a GPL implementation the library.)
精彩评论