#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved. @AUTHOR: ASJRD018 @NAME: AnsjerFormal @software: PyCharm @DATE: 2019/3/7 9:43 @Version: python3.6 @MODIFY DECORD:ansjer dev @file: mqtt_client.py @Contact: chanjunkai@163.com """ import paho.mqtt.client as mqtt HOST = "192.168.136.45" PORT = 1883 def test(): client = mqtt.Client() client.connect(HOST, PORT, 60) client.publish("chat", "hello chenfulin11111", 2) # client.loop() client.loop_forever() if __name__ == '__main__': test()