无法从 python 脚本访问 /dev/hidraw0

cannot access /dev/hidraw0 from python script

我正在尝试使用一些基本 python 代码在 Raspberry Pi 上从 USB HID 设备读取一些数据,但不断收到以下错误:

Traceback (most recent call last):
File "gnome1.py", line 2, in <module>
fd = open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK) 
TypeError: file() argument 2 must be string, not int

这是 Python 代码:

import os, sys
fd = open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK)
os.write(fd, "QPI\xBE\xAC\r")
os.read(fd, 512)

有人可以帮忙吗?

fd = os.open("/dev/hidraw0", os.O_RDWR|os.O_NONBLOCK)