【发布时间】:2017-11-11 08:05:31
【问题描述】:
我正在尝试将列表作为参数传递给线程函数。这个列表的长度可能会有所不同,但我不知道该怎么做。下面是我正在使用的代码。现在,我只想能够将列表放入线程函数中并在屏幕上打印出来。
#!/usr/bin/python
import threading
import Queue as queue
def generateRange(starting_chars=(*args)):
print str(starting_chars)
for i in range(32,126):
q = queue.Queue()
theArgs = [i,32,32]
threads = [ threading.Thread(target=generateRange,args=theArgs) ]
# generateRange([i,32,32])
for th in threads:
th.daemon = True
th.start()
我收到此错误:
File "./test.py", line 6
def generateRange(starting_chars=(*args)):
^
SyntaxError: invalid syntax
我做错了什么?
【问题讨论】:
标签: python list parameter-passing python-multithreading