TypeError: takes exactly 1 argument (2 given)
2018-03-23 19:46
2296 查看
执行以下脚本报错:
TypeError: takes exactly 1 argument (2 given)
主要是因为没有弄清python 类 中初始化需要加self
def send_pybot(self,msg):
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):
相关文章推荐
- django中报错TypeError: su() takes exactly 1 argument (2 given)的解决办法
- TypeError: checkcode() takes exactly 1 argument (2 given)
- PamIE 和COM调用IE出错: TypeError: getElementById() takes exactly 1 argument (2 given)
- Python: TypeError: XXX() takes exactly 1 argument (2 given)
- TypeError: distinct() takes exactly 2 arguments (3 given)
- TypeError: download_html() takes exactly 2 arguments (3 given)
- TypeError: __init__() takes exactly 2 arguments (1 given)(已解决)
- python安装pbkdf2 遇到错误TypeError: __call__() takes exactly 2 arguments (1 given)
- Python 'takes exactly 1 argument (2 given)' Python error
- TypeError: __init__() takes exactly 2 arguments (3 given)
- TypeError: unbound method must be called with class instance 1st argument
- Python - TypeError: unicode argument expected, got 'str'
- 解决错误TypeError: data argument can't be an iterator
- TypeError: string argument expected, got 'bytes'
- TypeError: parse() got an unexpected keyword argument 'transport_encoding'
- tensorflow 1.5 TypeError: __init__() got an unexpected keyword argument 'dct_method'
- python 调用super()初始化报错“TypeError: super() takes at least 1 argument”
- python3 translate() takes exactly one argument (2 given) in python error
- 关于TypeError: strptime() argument 1 must be str, not bytes解析
- Keras TypeError: run() got an unexpected keyword argument 'class_mode'