Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
多处理线程Python/encoding中的TypeError_Python_Multithreading_Encoding_Python Multithreading - Fatal编程技术网

多处理线程Python/encoding中的TypeError

多处理线程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

我在python中有一个列表,如下所示:

>>> 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
。然而,即使i
str(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'))