首页 > 解决方案 > python中的多线程-我想将字典作为参数传递

问题描述

我尝试将字典传递给线程函数

enemy_movement_thread = threading.Thread(target=enemy_movement, args= data)
enemy_movement_thread.start()

但发生错误:

Exception in thread Thread-8:
Traceback (most recent call last):
  File "C:\Users\ryanc\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
    self.run()
  File "C:\Users\ryanc\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
TypeError: enemy_movement() takes 1 positional argument but 7 were given

标签: pythonmultithreadingdictionary

解决方案


推荐阅读