嗨,我正在努力用这个代码让我的头绕着缩进水平 -
def getSolarFlowtemperature():
#Open the temperature sensor, read it and process the result
tfile = open("/sys/bus/w1/devices/28-000003086819/w1_slave")
text = tfile.read()
tfile.close()
temperature_data = text.split()[-1]
temperature = float(temperature_data[2:])
temperature = temperature / 1000
#This while function checks for the error temperatures, and tries to read the sensor again to get a proper value. After 10 tries it stops
count = 0
while temperature == -0.062 or temperature == -0.125:
time.sleep(2)
count = count + 1
print 'Temperature error on 28-000003086819, retrying'
tfile = open("/sys/bus/w1/devices/28-000003086819/w1_slave")
text = tfile.read()
tfile.close()
temperature_data = text.split()[-1]
temperature = float(temperature_data[2:])
temperature = temperature / 1000
if count > 10:
break
else:
return(temperature)
有人可以建议缩进在哪里不正确吗?
史蒂夫