python输出电脑上所有的串口名的方法
作者:男神是巴卫 时间:2022-06-23 20:56:03
输出电脑上所有的串口名:
import serial
import serial.tools.list_ports
from easygui import *
port_list = list(serial.tools.list_ports.comports())
if len(port_list) <= 0:
print "The Serial port can't find!"
else:
for i in list(port_list):
#print i[0] 仅仅输出端口号,像COM1、COM3、COM9
print i[1]
输出一个串口名:
# -*- coding: utf-8 -*
import serial
import serial.tools.list_ports
port_list = list(serial.tools.list_ports.comports())
if len(port_list) <= 0:
print "The Serial port can't find!"
else:
port_list_0 =list(port_list[0])
port_serial = port_list_0[0]
ser = serial.Serial(port_serial,9600,timeout = 60)
print "check which port was really used >",ser.name
来源:https://blog.csdn.net/baidu_33260220/article/details/78686622
标签:python,输出,电脑,串口名
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python 实现网页自动截图的示例讲解
2023-10-23 09:48:48
![](https://img.aspxhome.com/file/2023/6/112576_0s.jpg)
Jupyter notebook 启动闪退问题的解决
2023-11-17 21:08:58
![](https://img.aspxhome.com/file/2023/9/82689_0s.jpg)
python怎么去除字符串最后的换行符‘\\n’
2022-06-12 21:15:24
SQL基础语句总结
2011-03-11 14:54:00
无障碍网页应用 WAI-ARIA
2009-11-16 12:32:00
![](https://img.aspxhome.com/file/UploadPic/200911/16/1284_001-30s.png)
用户体验在商业利益面前什么都不是
2009-06-12 12:07:00
PHP如何实现HTTP验证
2023-09-04 05:32:46
Python matplotlib学习笔记之坐标轴范围
2022-04-21 16:24:28
![](https://img.aspxhome.com/file/2023/8/88038_0s.jpg)
Python编程pytorch深度卷积神经网络AlexNet详解
2022-02-18 10:28:40
![](https://img.aspxhome.com/file/2023/5/105235_0s.png)
详解Go语言微服务开发框架之Go chassis
2023-06-19 03:39:36
![](https://img.aspxhome.com/file/2023/8/89018_0s.jpg)
python基础之函数
2022-11-08 16:23:47
![](https://img.aspxhome.com/file/2023/8/79618_0s.png)
用Python编写个解释器实现方法接受
2023-01-11 15:50:08
![](https://img.aspxhome.com/file/2023/5/65505_0s.png)
bootstrap table列和表头对不齐的解决方法
2023-08-24 16:30:08
用 onerror 获取错误信息 js Debug
2008-11-03 19:08:00
JS 添加千分位与去掉千分位的示例
2010-08-20 06:18:20
ASP正则表达式技巧
2011-04-10 11:00:00
python3 中时间戳、时间、日期的转换和加减操作
2023-12-31 17:41:36
python+pytest接口自动化之session会话保持的实现
2021-10-15 15:45:31
![](https://img.aspxhome.com/file/2023/3/85183_0s.jpg)
Python基础之循环语句相关知识总结
2021-03-19 18:57:19
![](https://img.aspxhome.com/file/2023/5/105395_0s.png)
浅析php中array_map和array_walk的使用对比
2023-09-10 22:22:28