On Friday, 6 September 2019 20:15:40 UTC+2, MRAB  wrote:
> On 2019-09-06 18:11, Spencer Du wrote:
> > Hi
> > 
> > I want to print yes in gui.py but it does not get printed because of the 
> > json. How do I fix this. Execute embedded.py and then gui.py to test.
> > 
> > def on_message(client, userdata, msg):
> >     print("message recieved= " + msg.payload.decode())
> >     # print("File which you want to import(with .py extension)")
> >     print("message topic=", msg.topic)
> >     print("message qos=", msg.qos)
> >     print("message retain flag=", msg.retain)
> >     
>  >    if msg.payload[name] == "Hello world!":
>  >            print("Yes!")
>  >
> What is the value of the variable called 'name'? Or did you intend that 
> to be a string?
> 
>       if msg.payload["name"] == "Hello world!":
>               print("Yes!")


{"name": "Hello world!"} is a key value pair.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to