第一次使用 PyUSB,尝试对 OS X 的眼睛玩具(Play Station)进行逆向工程。尽管在尝试建立测试集合时出现以下错误。
Traceback (most recent call last):
File "eye.py", line 5, in <module>
dev = usb.core.find(0x054C,0x0155)
File "/Library/Python/2.7/site-packages/usb/core.py", line 824, in find
return [d for d in device_iter(k, v)]
File "/Library/Python/2.7/site-packages/usb/core.py", line 794, in device_iter
for dev in backend.enumerate_devices():
AttributeError: 'int' object has no attribute 'enumerate_devices'
当前代码...
import usb.core, time, usb
dev = usb.core.find(0x054C,0x0155)
if dev is None:
raise ValueError('Device not found') # if device not found report an error
最佳答案
usb.core.find
不与这样的位置参数一起使用。
我猜您有供应商 ID 和产品 ID。
如果是这样,您应该这样做:
usb.core.find(idVendor= 0x054C, idProduct= 0x0155)
如果您尝试提供位置参数,则需要设置 find_all
和 backend
的值。
关于python - PyUSB属性错误: 'int' object has no attribute 'enumerate_devices' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8555642/