[python package]pyserial
refer: windows下使用python进行串口通讯 - NiYintang的博客 - CSDN博客
1.Add serial lib
python-2.5 serial
Download pyserial-2.5.win32.exe, such as link https://pypi.org/project/pyserial/2.5/#files .Then click to install.
At last, using "import serial" to test wether install successful or not.
python-3.7 serial
If python is window edition, need to add some lib. Download from https://github.com/pyserial/pyserial, then copy "seral" directory into install directory C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Lib\site-packages. Last step, test wether the seral lib install success, method is input "import serial" in the python IDLE, as below:

2. Coding
import serial
import sys
ser=serial.Serial("COM10",115200,timeout=0.5)
while 1:
#ser.write('hello\r\n'.encode())
sys.stdout.write(ser.readline().decode())
sys.stdout.flush()
ser.close()
(end)
浙公网安备 33010602011771号