本文主要是介绍AssertionError: group argument must be None for now 错误解决方式,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
出错代码
# coding=utf-8
import threading,time
count=0
class MyThread(threading.Thread):def _init_(self,threadName):super(MyThread,self)._init_(name=threadName)def run(self):global countfor i in range(100):count=count+1time.sleep(0.3)print(self.getName(),count)
# if __name__ == '__main__':
for i in range(2):MyThread("MyThreadName:"+str(i)).start()
原因:将__init__写成_init_,注意是连续两个下划线
正确代码:
# coding=utf-8
import threading,time
count=0
class MyThread(threading.Thread):def __init__(self,threadName):super(MyThread,self).__init__(name=threadName)def run(self):global countfor i in range(100):count=count+1time.sleep(0.3)print(self.getName(),count)
# if __name__ == '__main__':
for i in range(2):MyThread("MyThreadName:"+str(i)).start()
这篇关于AssertionError: group argument must be None for now 错误解决方式的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!