Python 监控扫码枪输入
程序员文章站
2022-06-14 23:03:38
...
用python监控键盘扫描枪输入的内容
from pynput import mouse,keyboard
CODE = ""
# 处理键盘输入的数据
def on_release(key):
global CODE
try:
CODE += key.char
except Exception as e:
try:
if key == key.enter:
if "http" in CODE:
message = CODE.replace("http;","http:")
print(message)
CODE = ""
except Exception as e:
CODE = ""
#监听键盘扫码枪输入
with keyboard.Listener(on_release=on_release) as listener:
listener.join()
上一篇: Integer比较到底要不要equals
下一篇: Ubuntu更新源