Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在控制台中,您可以"\b"像这样打印以擦除光标左侧的字符(退格)
"\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
有关详细信息,请参阅http://ascii-table.com/ansi-escape-sequences.php。