擅长:python、mysql、java
<p>您需要从串行端口解码串行字节</p>
<p>替换代码中的Zustand=行</p>
<pre><code>Value_from_arduino = ser.readline()
Zustand = float(ser_bytes[0:len(Value_from_arduino )-2].decode("utf-8"))
</code></pre>
<p>请检查这里<a href="https://makersportal.com/blog/2018/2/25/python-datalogger-reading-the-serial-output-from-arduino-to-analyze-data-using-pyserial" rel="nofollow noreferrer">https://makersportal.com/blog/2018/2/25/python-datalogger-reading-the-serial-output-from-arduino-to-analyze-data-using-pyserial</a></p>
<p>如果编码效果不好,也可以尝试</p>
<pre><code>import struct
Zustand, = struct.unpack('<f',Value_from_arduino )
</code></pre>