【发布时间】:2016-03-23 00:53:54
【问题描述】:
首先,对不起,如果我的英语不好或有任何问题,这是我的第一个“帖子”。
我正在尝试使用 USB 游戏手柄通过 gpiozero 打开和关闭 LED。
我在尝试执行程序时出错:
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 行 味精 += [ord(char)] TypeError: ord() 预期长度为 1 的字符串,但找到了 int
我能做些什么来解决这个问题?
谢谢。
【问题讨论】:
-
请把代码和错误信息都添加为“文本”。
-
已经搞定了,希望对你有所帮助。
-
你能发布你遇到的错误吗?
-
是的,抱歉我忘记了。
-
我真的需要这个帮助,希望你能帮助我
标签: python-3.4 raspberry-pi2 gpio led gamepad