如果用户输入退格,有没有办法在python中返回input()



在python中按下退格键后,是否有任何方法可以返回用户的输入,而不仅仅是回车键?我知道如何通过使用text=input(>"(和使用keypad.is_pressed('\b'(来检查用户是否使用键盘模块输入了退格来获得用户的输入。但我想在用户打字时检查一下。有办法做到吗?

msvcrt库适用于我

PS:我使用windows操作系统

import msvcrt
x="hehe"
data=""
while x!="b":
x=msvcrt.getch()
x=x.decode("utf-8")
data+=x
print("Gotcha !",data)

最新更新