'\b' doesn't print backspace in PyCharm console

我是研究僧i 提交于 2019-11-28 07:43:35

问题


I am trying to update the last line in PyCharm's console. Say, I print a and then I want to change it to c. However, I encounter the following problem. When I run:

print 'a\bc'

it prints

a c

while the desired output (which is also what I see in the Windows console) is:

c

Is there a way to move the cursor back in PyCharm's console? or maybe delete the whole line?


回答1:


It's a known bug: http://youtrack.jetbrains.com/issue/PY-11300

If you care about this, please get an account on the bug tracker and upload the bug to give it more attention.




回答2:


This is not a bug, this is a limitation of the interactive console found both in PyCharm, and in the IDLE shell.

When using the command prompt of windows, or a linux shell - the \b character is interpreted as a backspace and implemented as it is being parsed - However, in the interactive console of PyCharm and IDLE the \b character and many others are disabled, and instead you simply get the ASCII representation of the character (a white space in most cases).




回答3:


The \r works. I know this is ASCII Carriage Return, but i use this as a workaround

print("\ra")
print("\rc")

will yield in c in the console

By the way, backspace is a ASCII Character



来源:https://stackoverflow.com/questions/19925189/b-doesnt-print-backspace-in-pycharm-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!