Python struct模块-解压顺序

时间:2019-04-02 04:34:11

标签: python ubuntu struct io

我正在使用这种环境,

<ion-datetime display-format="DD MMM YYYY" month-short-names="ene, feb, mar, abr, may, jun, jul, ago, sep, oct, nov, dic" color="light" placeholder="Seleccione fecha" required></ion-datetime>

我有Logitech G29赛车轮,想知道它的输入信息。

Ubuntu 16.04 Kernel 4.15

如何找出元组的每个元素代表什么?
例如,
0〜4:顺序 5〜6:值 7:代码

如果不打开包装,我想它会像
b'x10 \ xac \ xa7 \ x01 \ xd2 \ xa0 \ x02 \ x00'
那么十六进制代码与import struct infile_path = "/dev/input/js0" EVENT_SIZE = struct.calcsize("l") # I want to have 8 bytes of each action(event) file = open(infile_path, "rb") while 1: event = file.read(EVENT_SIZE) # not sure how many elements of tuple will be generate in here _, _, _, _, ... _, = struct.unpack("l", event) ## here # If I don't unpack, I guess it will be like # b'x10\xac\xa7\x01\xd2\xa0\x02\x00' 元素的顺序相同吗?

0 个答案:

没有答案