안녕 난이 코드 - 내 머리 라운드 indentaion 수준을 얻기 위해 struging하고파이썬 들여 쓰기 초보자
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)
들여 쓰기가 잘못 어떤 사람의 조언은 할 수 있습니까?
스티브
감사합니다. 이 코드는 내가 들었을하고 내 자신의 사용을 위해 내가 초보자로 수정 :) 아이디어는 그 기능이 10 번 내가 믿는 가치를 검색하려고합니다. –
Break는 루프 구조에서 벗어나 반복을 중지하므로 루프에 중첩되어야합니다. 여기서 우리는 잠시 동안 휴식을 볼 수 있습니다. 그래서 휴식은 잠시 동안을 의미합니다. 루프가 하나 더 있으면 내부 루프에서 빠져 나옵니다. 반복문을 사용하는 것은 불가능합니다. 아무런 반복이 없기 때문에 아무 의미가 없습니다. 시도해보십시오. 오류가 발생합니다. – lc2817