我正在为客户端编写一个程序,该程序通过客户端记录的内置平均值无线电从服务器接收平均值字符串。我收到一个 TypeError 说:“不支持的类型:'int','NoneType'”。
这是我的代码:
from microbit import *
import radio
radio.on()
blink = Image("99999:"
"99999:"
"99999:"
"99999:"
"99999")
radio.send("power on")
while True:
incoming = radio.receive()
if incoming is not None:
incoming = float(incoming)
sleep(500 - running_time() % 500)
acceleration = accelerometer.get_z()
radio.send(str(acceleration))
acceleration = float(acceleration)
if acceleration > 2 * incoming or acceleration < .5 * incoming:
display.show(blink)
microbit.sleep(150)
display.clear()
microbit.sleep(150)
错误发生在这一行:
if acceleration > 2 * incoming or acceleration < .5 * incoming: