问题描述
'''
from pynput import keyboard
old_list=['a','b','c','d','e','f','g','h']
new_list=[]
for x in old_list:
print('Press 1 to add '+x+' to new list:')
with keyboard.Events() as events:
event = events.get(1e6)
if event.key == keyboard.KeyCode.from_char('1'):
new_list.append(x)
print(new_list)
'''
output:
Press 1 to add a to new list:
Press 1 to add b to new list:
Press 1 to add c to new list:
Press 1 to add d to new list:
Press 1 to add e to new list:
Press 1 to add f to new list:
Press 1 to add g to new list:
Press 1 to add h to new list:
['a','g']
12212
我的担忧:
- 当我按下一个数字时,比如 1,它被记录了不止一次。我试图尽可能快地按下和释放,但没有用。
- 最后不应该打印(返回)输入的字符
我正在使用 windows vista。 Python 版本 3.4.2
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)