手机
当前位置:查字典教程网 >脚本专栏 >python >Python RuntimeError: thread.__init__() not called解决方法
Python RuntimeError: thread.__init__() not called解决方法
摘要:在写一个多线程类的时候调用报错RuntimeError:thread.__init__()notcalled复制代码代码如下:classNo...

在写一个多线程类的时候调用报错

RuntimeError: thread.__init__() not called

复制代码 代码如下:

class NotifyTread(threading.Thread):

def __init__(self, params):

threading.Thread.__init__(self) #here。。。。。。

self.params = params

def run(self):

print "start notify............"

time.sleep(10)

print notify_tran(self.params)

print "end notify.............."

在init中要先初始化Thread,然后在给参数赋值,就能解决了。

也就是不能缺少

threading.Thread.__init__(self)

这是一个使用的注意地方。

【Python RuntimeError: thread.__init__() not called解决方法】相关文章:

Python ljust rjust center输出

python pickle 和 shelve模块的用法

Python中__init__和__new__的区别详解

python BeautifulSoup使用方法详解

Python实现全局变量的两个解决方法

python解决字典中的值是列表问题的方法

Python 的 with 语句详解

Python中的map、reduce和filter浅析

从零学python系列之新版本导入httplib模块报ImportError解决方案

Python中os和shutil模块实用方法集锦

精品推荐
分类导航