git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help me fix a problem


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!")