【发布时间】:2021-10-07 12:56:41
【问题描述】:
在以传统方式创建线程时,我想传递列表和字典对象;该怎么做?
例如:
def expectslist(**kwargs):
list=kwargs.values -- not working
def expectsdict(**kwargs):
dictobject=kwargs.values -- not working
def main():
thread1 = Thread(target =expectslist, (args=mylist)) # mylist is list of objects
thread2 = Thread(target =expectsdict, (args=mydict)) # mydict is dictionary of objects (key-objects pair)
【问题讨论】:
-
首先,你声明的函数都没有期望列表。
标签: python python-3.x multithreading