Python RuntimeError: thread.__init__() not called
2015-08-25 17:15
811 查看
直接上代码:
# encoding: UTF-8
import threading
import time
class MyThread(threading.Thread):
def run(self):
for i in range(3):
time.sleep(1)
msg = "I'm "+self.ip+' @ '+str(i)
print msg
def __init__(self,ip):
threading.Thread.__init__(self) //没有该语句的话则会出现Python RuntimeError: thread.__init__() not called异常
self.ip = ip
def test():
for i in range(5):
t = MyThread("hello"+str(i))
t.start()
if __name__ == '__main__':
test()
# encoding: UTF-8
import threading
import time
class MyThread(threading.Thread):
def run(self):
for i in range(3):
time.sleep(1)
msg = "I'm "+self.ip+' @ '+str(i)
print msg
def __init__(self,ip):
threading.Thread.__init__(self) //没有该语句的话则会出现Python RuntimeError: thread.__init__() not called异常
self.ip = ip
def test():
for i in range(5):
t = MyThread("hello"+str(i))
t.start()
if __name__ == '__main__':
test()
相关文章推荐
- re,re.search,
- 【Python 练习】随机显示不重复的单词
- python的datetime模块实用小记
- python property装饰器
- Python图像处理库:Pillow 初级教程
- python学习--核心编程3习题解答以及知识点记录
- python学习笔记6—文件操作来生成船只侧面图像的描述文件
- python build in functions
- python学习笔记5—序列与列表的操作
- selenium 不断切换代理 打淘宝小店流量
- python中的set
- python - 跨平台全局快捷键解决方案
- liunx下安装第三方Python(PIP安装)
- Play 迷宫 with python and pygame
- 【python编程】python引导实例参考
- 轻松python文本专题-判断对象里面是否是类字符串(推荐使用isinstance(obj,str))
- 轻松python文本专题-判断对象里面是否是类字符串(推荐使用isinstance(obj,str))
- 用Python操作Mysql
- 使用setuptools打包python项目
- python 之tinyproxy