开发者社区> 问答> 正文

Python多线程问题 请大虾们帮忙看看~~谢谢了? 400 报错

Python多线程问题 请大虾们帮忙看看~~谢谢了? 400 报错

我用的平台是PythonWin,版本是3.3。
当输入t = Mythread(2) 生成Mythread对象时,就出错了,现在还没有头绪,望指教!

>>> import threading >>> import time >>> class Mythread(threading.Thread): ... 	def init(self,id): 	 ... 		threading.Thread.init(self) ... 		self.id = id ... 	def run(self): ... 		x = 0 ... 		time.sleep(60) ... 		print (self.id) ... 		 >>> def func(): ... 	t.start() ... 	for i in range(5): ... 		print (i) ... 		 >>> t = Mythread(2) Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "E:\Program Files (x86)\Python33\lib\threading.py", line 536, in init assert group is None, "group argument must be None for now" AssertionError: group argument must be None for now >>>

  File "<interactive input>", line 1, in <module>
  File "E:\Program Files (x86)\Python33\lib\threading.py", line 536, in init
    assert group is None, "group argument must be None for now"
AssertionError: group argument must be None for now

展开
收起
爱吃鱼的程序员 2020-06-05 12:06:35 871 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    引用来自“不必在乎我是谁”的答案

    python 2.7 表示没有任何问题,无论是在控制台还是用 .py 文件。
    用python2.5.1和python2.6.6 会出现这个问题,安装了python2.7就没有这个问题了。
    ######python 2.7 表示没有任何问题,无论是在控制台还是用 .py 文件。######回复 @不必在乎我是谁 : 我全部删除干净了,安装还是不行,我换了个pywin32-218.win-amd64-py2.7这个版本,安装可以,但双击pythonwin时,提示下面的错误:应用程序无法启动,因为应用程序的并行配置不正确。我要怎么解决呢?######回复 @火影熊 : 可能是你安装的版本太多了,版本之间有冲突。最好卸载掉所有版本后删除Python文件夹,再重新安装试试######回复 @不必在乎我是谁 : 我安装pywin32-214.win32-py2.7,之后在E:\Python27\Lib\site-packages\pythonwin路径下双击pythonwin图标后,就提示错误,信息如下:The application can not locate win32ui.pyd(or python)(126)找不到指定的模块。请问要怎么解决呢?谢谢######回复 @火影熊 : 我的确实可以跑,win7 x64 + py2.7……######你好,谢谢你的帮助。我在python2.5和2.7上都试了我的这段程序,还是同样的错误。######
    class Thread:
    	__initialized = False
    	# Need to store a reference to sys.exc_info for printing
    	# out exceptions when a thread tries to use a global var. during interp.
    	# shutdown and thus raises an exception about trying to perform some
    	# operation on/with a NoneType
    	__exc_info = _sys.exc_info
    	# Keep sys.exc_clear too to clear the exception just before
        # allowing .join() to return.
        #XXX __exc_clear = _sys.exc_clear
       
        def __init__(self, group=None, target=None, name=None,args=(), kwargs=None, *, daemon=None):
    		assert group is None, "group argument must be None for now"
    		if kwargs is None:
    		kwargs = {}
    		self._target = target
    		self._name = str(name or _newname())
    		self._args = args
    		self._kwargs = kwargs
    		if daemon is not None:
    			self._daemonic = daemon
    		else:
    			self._daemonic = current_thread().daemon
    		self._ident = None
    		self._started = Event()
    		self._stopped = False
    		self._block = Condition(Lock())
    		self._initialized = True
    		# sys.stderr is not stored in the class like
    		# sys.exc_info since it can be changed between instances
    		self._stderr = _sys.stderr
    		_dangling.add(self)
    ######

    试试 t=Mythread(None)


    ######还是一样的错误!######用 python 2.6.6 就好啦!我用的就是个者版本号,没有报错现象
    ######我安装pywin32-214.win32-py2.7,之后在E:\Python27\Lib\site-packages\pythonwin路径下双击pythonwin图标后,就提示错误,信息如下:The application can not locate win32ui.pyd(or python)(126)找不到指定的模块。请问要怎么解决呢?谢谢
    2020-06-05 13:05:16
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载