擅长:python、mysql、java
<p>要进行读取,需要先打开侦听端口(超时),例如:</p>
<pre><code>ser = serial.Serial('/dev/cu.usbserial-A901HOQC', 19200, timeout=5)
x = ser.read() # read one byte
s = ser.read(10) # read up to ten bytes (timeout)
line = ser.readline() # read a '\n' terminated line
ser.close()
</code></pre>
<p>查看更多详细信息<a href="http://pyserial.sourceforge.net/shortintro.html" rel="nofollow">here</a>。</p>