python - 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
解决方案
推荐阅读
- mysql - 每次新数据进入数据库时如何运行python脚本
- javascript - 我如何在javascript中每个[“”]分割一个字符串
- python - 如何解决这个问题(Pytorch RuntimeError: 1D target tensor expected, multi-target not supported)
- javascript - 为变量赋值时,jQuery.parseHTML 是如何工作的?
- laravel - Laravel:auth()->尝试未定义的方法
- python - 我需要获取一个变量(用户电子邮件)并将其作为参数传递给嵌套类,但我无法使其工作
- asp.net - 即使我设置了静态机器密钥,oauth 持有者刷新令牌在应用程序池回收时也无效
- tinymce - TinyMCE - 向编辑器添加一个简单的按钮(不是工具栏)
- haskell - 大输入的阶乘函数返回负数
- sql - 根据商店选择每个产品的最新余额(SQL)