【发布时间】:2012-05-03 02:28:59
【问题描述】:
在控制台中,您可以像这样打印"\b" 以擦除光标左侧的字符(退格)
print "the last char is going to be erased\b" # the last char is going to be erased
如何只向左移动一个位置而不是擦除(左箭头)?
【问题讨论】:
在控制台中,您可以像这样打印"\b" 以擦除光标左侧的字符(退格)
print "the last char is going to be erased\b" # the last char is going to be erased
如何只向左移动一个位置而不是擦除(左箭头)?
【问题讨论】:
这取决于终端类型和连接,但您通常可以假设 ANSI 光标移动,因此光标左侧是 ESC + '[' + 'D':
print "The cursor should be between the arrows: -> <-\e[D\e[D\e[D"
readline
【讨论】:
SetConsoleCursorPosition())。