1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#!/usr/bin/env python # -*- 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 |
转载请注明:徐自远的乱七八糟小站 » python serial 获取所有的串口名称