rrr
# coding:utf-8 import pika username = 'feng' password = 'nihao' host = '192.168.1.144' credentials = pika.PlainCredentials(username, password) connection = pika.BlockingConnection(pika.ConnectionParameters(host=host, credentials=credentials, port=5672)) channel = connection.channel() channel.queue_declare(queue='trans_queue',auto_delete=True) channel.basic_publish(exchange='', routing_key='hello', body='Hello World!') print "[x] Sent 'Hello World!'" connection.close()