多处理线程Python/encoding中的TypeError
我在python中有一个列表,如下所示:多处理线程Python/encoding中的TypeError,python,multithreading,encoding,python-multithreading,Python,Multithreading,Encoding,Python Multithreading,我在python中有一个列表,如下所示: >>> print chunked_fsq_ids [u'4bee84983686c9b6b794246e', u'4cbfb9f10d22ef3bc4e12c70', u'4b570230f964a520aa2228e3', u'51fd214d454ab82ac66e1211', u'4baf22eef964a5201ced3be3'] 我想创建一个多线程进程: def getter(id): print id fo
>>> print chunked_fsq_ids
[u'4bee84983686c9b6b794246e', u'4cbfb9f10d22ef3bc4e12c70', u'4b570230f964a520aa2228e3', u'51fd214d454ab82ac66e1211', u'4baf22eef964a5201ced3be3']
我想创建一个多线程进程:
def getter(id):
print id
for fsq_id in chunked_fsq_ids:
t = threading.Thread(target=getter, args=( fsq_id ))
t.start()
threads.append(t)
map(lambda t: t.join(), threads)
但是,我收到一个(循环)类型错误:
Exception in thread Thread-461:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 808, in __bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 761, in run
self.__target(*self.__args, **self.__kwargs)
TypeError: getter() takes exactly 1 argument (24 given)
每个fsq\u id
都有24个字符,就像我在给出一个列表一样
我的编码有问题吗,或者我错过了什么?
fsq\u id
是Unicode
。然而,即使istr(fsq\u id)
或'fsq\u id.encode('utf-8'),我也会遇到相同的错误。有解决方案吗?您缺少尾随,
:
t = threading.Thread(target=getter, args=(fsq_id,))
以下解释为:
t=threading.Thread(target=getter,args=('4','b','e','e','8','4','9','8','8','c','9','b','6','b','7','9','4','2','4','6','e'))
:
t = threading.Thread(target=getter, args=('4bee84983686c9b6b794246e'))