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

 

posted @ 2019-03-19 09:53  iSZ  阅读(938)  评论(0编辑  收藏  举报