[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 but it does not get printed because of the json. How do I fix this. Execute and then 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!":