'TypeError: unsupported format string passed to NoneType._format_
So i have to do a capstone on a raspberri pi weather station. Yesterday my code worked fine and today it doesnt work at all. My code is:
from guizero import App, Text, PushButton, info
from time import sleep
import sys
import Adafruit_DHT
DHT_SENSOR = Adafruit_DHT.AM2302
DHT_PIN = 4
app=App(title="Temperature_Humidity GUI", layout="grid", width="800", height="480")
#def close_gui():
#sys.exit()
def temp():
humidity, temperature_c = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
temperature=temperature_c * (9/5)+32
text.value="{0:0.2f}".format(temperature)
def humid():
humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
text2.value="{0:0.2f}".format(humidity)
humidity, temperature_c = 2,3
temperature=temperature_c * (9/5)+32
import datetime
def time():
time = datetime.datetime.now()
stringtime = time.strftime("%I:%M:%S %p")
info("Time", stringtime)
PushButton(app, command=temp, text="Check Temperature", width=15,height=3,grid=[0,0])
text = Text(app, text="{0:0.2f}".format(temperature), grid=[1,0])
Text(app, text="*F", grid=[2,0])
PushButton(app, command=humid, text="Check Humidity", width=15, height=3, grid=[0,1])
text2 = Text(app, text="{0:0.2f}".format(humidity), grid=[1,1])
Text(app, text="%", grid=[2,1])
PushButton(app, command=time, text="Check Time", width=15, height=3, grid=[0,2])
#PushButton(app, close_gui, text="close", grid=[1,2])
app.display()
the error is: TypeError: unsupported format string passed to NoneType.format
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
