Help me fix a problem
MRAB
python at mrabarnett.plus.com
Fri Sep 6 14:15:23 EDT 2019
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!")
More information about the Python-list
mailing list