Advertisement
Guest User

new

a guest
Nov 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. import serial.tools.list_ports
  2.  
  3. plist = list(serial.tools.list_ports.comports())
  4.  
  5. if len(plist) <= 0:
  6.     print("没有发现端口!")
  7. else:
  8.     plist_0 = list(plist[0])
  9.     serialName = plist_0[0]
  10.     serialFd = serial.Serial(serialName, 9600, timeout=60)
  11.     print("可用端口名>>>", serialFd.name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement