Simple way to query connected USB devices info in Python?

后端 未结 6 2165
独厮守ぢ
独厮守ぢ 2020-11-28 03:17

How can we query connected USB devices info in Python? I want to get UID Device Name (ex: SonyEricsson W660), path to device (ex: /dev/ttyACM0)

And also what would b

6条回答
  •  孤街浪徒
    2020-11-28 04:04

    If you are working on windows, you can use pywin32 (old link: see update below).

    I found an example here:

    import win32com.client
    
    wmi = win32com.client.GetObject ("winmgmts:")
    for usb in wmi.InstancesOf ("Win32_USBHub"):
        print usb.DeviceID
    

    Update Apr 2020:

    'pywin32' release versions from 218 and up can be found here at github. Current version 227.

提交回复
热议问题