首先,对不起,如果我的英语不好或有任何问题,这是我的第一个“帖子”。
我正在尝试使用 USB 游戏手柄打开和关闭 LED gpiozero
。
尝试执行程序时出现错误:
import sys
from gpiozero import LED
led = LED(17)
pipe = open('/dev/input/js0', 'rb')
msg = []
while 1:
for char in pipe.read(1):
msg += [ord(char)]
if len(msg) == 8:
if msg[6] == 1:
if msg[4] == 1:
print ('button', msg[7], 'down')
led.on()
else:
print ('button', msg[7], 'up')
led.off()
msg = []
错误:文件“script.py”,第 13 行,在 <module> msg += [ord(char)] 类型错误:ord() 预期的字符串长度为 1,但找到了 int
我能做些什么来解决这个问题?
谢谢。