我试图写入与Raspbian安装的Raspberry Pi 3的USB设备。
错误:
File "<stdin>", line 1
h.write([81 80 73 71 83 183 169 13])
^
SyntaxError: invalid syntax
代码
#!/usr/bin/python
import hid
h = hid.device()
h.open(0x0665, 0x5161)
h.set_nonblocking(1) // Returns 0
h.write([0, 63, 35, 35] + [0] * 61) // Returns -1
h.write([81 80 73 71 83 183 169 13]) //Throws error above.
此代码怎么了?根据库中的文档,它接受整数列表。
我将其用作参考:https://github.com/trezor/cython-hidapi/blob/master/master/try.py.py
列表中缺少逗号分隔。
列表应为,
(逗号(分离,
更改h.write([81 80 73 71 83 183 169 13])
to
h.write([81, 80, 73, 71, 83, 183, 169, 13])