我一直在尝试通过使用 python 中的 evdev 条形码扫描仪来获取字符串输出。 这是我的剧本...
from evdev import *
dev = InputDevice('/dev/input/event2')
print(dev)
for event in dev.read_loop():
if event.type == ecodes.EV_KEY:
print(categorize(event))
当我在此之后扫描时,我得到以下输出:
key event at 1526024323.229556, 5 (KEY_4), down
key event at 1526024323.237564, 5 (KEY_4), up
key event at 1526024323.245549, 11 (KEY_0), down
key event at 1526024323.253534, 11 (KEY_0), up
key event at 1526024323.261553, 2 (KEY_1), down
key event at 1526024323.269538, 2 (KEY_1), up
key event at 1526024323.277549, 10 (KEY_9), down
key event at 1526024323.285565, 10 (KEY_9), up
key event at 1526024323.293555, 2 (KEY_1), down
key event at 1526024323.301535, 2 (KEY_1), up
key event at 1526024323.309553, 7 (KEY_6), down
key event at 1526024323.317533, 7 (KEY_6), up
key event at 1526024323.325553, 10 (KEY_9), down
key event at 1526024323.333537, 10 (KEY_9), up
key event at 1526024323.341554, 3 (KEY_2), down
key event at 1526024323.349537, 3 (KEY_2), up
key event at 1526024323.357552, 2 (KEY_1), down
key event at 1526024323.365537, 2 (KEY_1), up
key event at 1526024323.373554, 2 (KEY_1), down
key event at 1526024323.381535, 2 (KEY_1), up
key event at 1526024323.389555, 3 (KEY_2), down
key event at 1526024323.397535, 3 (KEY_2), up
key event at 1526024323.405552, 4 (KEY_3), down
key event at 1526024323.413537, 4 (KEY_3), up
key event at 1526024323.421554, 10 (KEY_9), down
key event at 1526024323.429537, 10 (KEY_9), up
key event at 1526024323.437579, 28 (KEY_ENTER), down
key event at 1526024323.445533, 28 (KEY_ENTER), up
我不明白,因为我是python的新手,但我认为在这种情况下不会有太大区别。 我已经检查了其他相关问题,但我无法从中得出答案。 请帮帮我。
我如何过滤掉起伏并保持跌幅。
条码扫描器通常(总是?(充当键盘。使用条形码扫描仪扫描条形码在计算机上看起来与插入键盘、键入数字并按 Enter 完全相同。
如果您打开命令提示符或文本编辑器并扫描某些内容,您是否看到数字看起来像您键入了它?
通常你不需要使用低级接口来与之交互 - 只需使用内置的input()