执行以下脚本报错:
TypeError: takes exactly 1 argument (2 given)

#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
Created on 2017-12-18
@author: sxli

'''
import redis
import sys
class  PublishChannel(object):
    #kword = u"桌面".encode('gb2312')
    def send_pybot(self,msg):
        message=["msg1","msg2","msg3"]
        '''
        msg1:对参与者端共享app进行外窗口操作
        msg2:对参与者端共享app进行内窗口操作
        msg3:参与者端托盘断开连接重连操作

        '''
        pool=redis.ConnectionPool(host='192.168.3.58',port=6379,db=0)
        r = redis.StrictRedis(connection_pool=pool)
        # input = raw_input("publish:")
        if msg in message:
            r.publish('spub', msg)
        if  input == 'over':
            print '停止发布'
            # break; 
if __name__ == "__main__":
    Do = PublishChannel()
    Do.send_pybot(sys.argv[1])
    print "finish msg to Channel !"

主要是因为没有弄清python 类 中初始化需要加self
def send_pybot(self,msg):

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐