python打印电脑串口的信息
1 # -*- coding:utf-8 -*- 2 3 from serial.tools.list_ports import comports 4 5 port_list = list(comports()) 6 if len(port_list) == 0: 7 print('Not found Serial Ports') 8 else: 9 for i in range(len(port_list)): 10 print(port_list[i]) #print the serial port infomation