【Python】Windows中Python Serial获取PC下串口名称

2017-09-12 19:24:36来源:CSDN作者:u014647208人点击

分享

windows中,使用python进行串口编程需要安装一个Serial模块pyserial
详细的使用信息可以阅读pySerial的文档http://pythonhosted.org/pyserial/

#!/usr/bin/env python#-*- coding: utf-8 -*import serialimport serial.tools.list_portsplist = list(serial.tools.list_ports.comports())if len(plist) <= 0:    print ("The Serial port can't find!")else:    plist_0 =list(plist[0])    serialName = plist_0[0]    serialFd = serial.Serial(serialName,9600,timeout = 60)    print ("check which port was really used >",serialFd.name)

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台