我试图用Pyusb生成产品/供应商ID列表,但遇到了问题。我在网上找到了一个来自orangecoat的建议。在
import sys
import usb.core
import usb.util
dev = usb.core.find(find_all=True)
if dev is None:
raise ValueError('Device not found')
cfg = dev.get_active_configuration()
但是Python给出了以下错误:
^{pr2}$有人能帮我理解我为什么会犯这个错误吗? 谢谢你
你已经快到了,但是你需要迭代你的
dev
对象,它是一个生成器。在保存此脚本
test.py
然后,运行这个
sudo python test.py
在使用python3的Windows上,您需要将
d = dev.next()
更改为d = next(dev)
(正如@gabin在评论中指出的那样)相关问题 更多 >
编程相关推荐