问题
I am very new to using PyUSB. I have some USB devices connected to my machine and am trying to get some of their properties. Based on what I have learnt from other examples using PyUSB, I have produced a short program in Linux. Here is a snip of the program:
busses = usb.busses()
for bus in busses:
devices = bus.devices
for dev in devices:
print dev.filename
print bus.dirname
print dev.idProduct
When I checked the output, both dev.filename and bus.dirname are empty string for all the devices. The dev.idProduct is correct.
Can someone help with these questions please? (1) What is dev.filename? (2) What is bus.dirname? (3) Can both of these properties empty?
Thanks.
回答1:
The device number is in devnum:
busses = usb.busses()
for bus in busses:
devices = bus.devices
for dev in devices:
print dev.devnum #filename is empty!!
print bus.dirname
print dev.idProduct
来源:https://stackoverflow.com/questions/38570959/pyusb-why-are-bus-dirname-and-dev-filename-empty-string