简体   繁体   English

Python3 shell 在 Linux 上按退格键打印 ^H

[英]Python3 shell prints ^H on pressing backspace key on Linux

On python3 shell launched on bash misbehaves on pressing arrows or backspace.在 bash 上启动的 python3 shell 在按下箭头或退格键时行为不端。
It prints ^H for backspace, and I can remove these characters using Ctrl+backspace or shift+backspace .它为退格打印^H ,我可以使用Ctrl+backspaceshift+backspace删除这些字符。
But I don't want to do this workaround for backspace (I can do, but I can't ask all my users to follow),但是我不想为退格执行此解决方法(我可以这样做,但我不能要求所有用户都遵循),
So how to address this issue?.那么如何解决这个问题呢?
BTW, I don't see this issue in python2 shell.顺便说一句,我在 python2 shell 中没有看到这个问题。
OS: 5.4.40-OpenNetworkLinux操作系统:5.4.40-OpenNetworkLinux

python3
Python 3.8.10 (main, Jul 13 2022, 06:53:48)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.systemm^H^H^H

Try stty erase ^H .尝试stty erase ^H If you regret, just use stty erase ^?如果你后悔,就用stty erase ^? . . If you don't want to do this every time, put stty erase ^H into .bash_profile.如果您不想每次都这样做,请将stty erase ^H放入 .bash_profile。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM