我有以下代码,我想它列出了PC上端口的信息。 我的电脑有1个COM端口和10个USB 2.0端口。 但是当我执行时,它只显示COM端口信息。
这是我的python代码:
import serial.tools.list_ports
for port in serial.tools.list_ports.comports():
print("hwid:", port.hwid)
print("device:", port.device)
print("name:", port.name)
print("description:", port.description)
print("pid:", port.pid)
print("vid:", port.vid)
print("serial_number:", port.serial_number)
print("location:", port.location)
print("manufacturer:", port.manufacturer)
print("product:", port.product)
print("interface:", port.interface)
这是结果:
hwid: ACPI\PNP0501\1
device: COM1
name: None
description: Communications Port (COM1)
pid: None
vid: None
serial_number: None
location: None
manufacturer: (Standard port types)
product: None
interface: None
您会看到没有列出USB设备。
你有什么想法?