你试过pyUsb吗?这里有你可以做的一些片段:
pip install pyusb
Run Code Online (Sandbox Code Playgroud)
这是pyUsb的一个很好的教程.
有关更多文档,请使用带有dir()和help()的Python交互模式.
@systempuntoout 的回答很好,但今天我找到了一种更简单的方法来查找或迭代所有设备:usb.core.find(find_all=True)
下面以你的例子为例:
import usb
for dev in usb.core.find(find_all=True):
print("Device:", dev.filename)
print(" idVendor: %d (%s)" % (dev.idVendor, hex(dev.idVendor)))
print(" idProduct: %d (%s)" % (dev.idProduct, hex(dev.idProduct)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
32450 次 |
| 最近记录: |