python打印电脑串口的信息

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于python打印电脑串口的信息的主要内容,如果未能解决你的问题,请参考以下文章