我不知道为什么,但我在计算AIQhum时得到了tuple,在这种情况下,hum是>;我得到了这个元组(0190669.42),我不知道为什么我首先得到了0。如何避免它强制不获取第二个值的元组?多谢各位
def getCO2(self):
try:
hum = sensor.data.humidity
gas=0
for x in range(10):
gas= gas+sensor.data.gas_resistance
gasAvr=gas/10
if hum < 38:
AIQhum = -0, 625 * hum + 25
if hum >= 38 and hum <= 42:
AIQhum = 0
if hum > 42:
AIQhum = 0,4167 * hum - 16.667
#time.sleep(30)
print(gasAvr)
if gasAvr > 50000:
gasAvr = 50000
if gasAvr < 5000:
gasAvr = 5000
IAQresistencia=-0.0017*gasAvr+83.33
IAQglobal=AIQhum+IAQresistencia
IAQ2=IAQglobal*5
if IAQ2<=50:
message="Good"
if IAQ2>=51 and IAQ2<=100:
message="Moderate"
if IAQ2>=101 and IAQ2<=150:
message="Unhealghy for sensitive groups"
if IAQ2>=151 and IAQ2<=200:
message="Unhealthy"
if IAQ2>=201 and IAQ2<=300:
message="Very Unhealthy"
if IAQ2>=301 and IAQ2<=500:
message="Hazarous"
在一些地方,您使用逗号代替小数点,例如
0,4167
而不是0.4167
0,4167
被解释为元组(0, 4167)
或甚至(0, 4167 * hum - 16, 667)
您需要使用
.
作为小数点,例如:(0.4167 * hum - 16.667)
问题是“,”这个词。我把它改成了“.”,现在它开始工作了
相关问题 更多 >
编程相关推荐