from getch import getch
def pr(s):
print(s, end='', flush=True)
def get_word():
DELETE = 127 # ASCII code
word = ''
c = ''
while not c.isspace():
c = getch()
if ord(c) == DELETE:
pr('\r' + ' ' * len(word) + '\r')
word = word[:-1]
pr(word)
if c.isprintable():
word += c
pr(c)
print('\n')
return word
docs非常清楚。你知道吗
不要这样做,因为
getche()
被记录为有你说你不想要的行为。你知道吗打电话给
getch()
,并根据您的要求负责“回音”或维护显示器。你知道吗例如,此代码实现了您想要的:
官方的定义是:
你说你想写一个打字训练程序,我认为最好的解决方案是使用
curses
库来完成这样的任务。你知道吗在UNIX系统上,它附带了python的默认安装,如果您针对windows系统,我发现windows-curses可以极大地增加支持。你知道吗
基本上,您可以在官方文档的this页中找到HOWTO指南。你知道吗
下面是创建文本框小部件的用法示例
curses.textpad模块应该对您非常有用。你知道吗
下面是使用
windows-curses
模块你可以使用这个库做很多事情,我建议你继续阅读我提供的链接上的文档。你知道吗
相关问题 更多 >
编程相关推荐