当我发送 <class 'pandas.core.frame.DataFrame'> 作为 python 中的参数时,为什么我在方法中收到多个值
Why am I receiving multiple values in the method when I'm sending a <class 'pandas.core.frame.DataFrame'> as args in python
我正在实施一个多线程概念,它将大容量 <class 'pandas.core.frame.DataFrame'>
分成一些块。当我将它作为 args 发送到目标函数时,我收到类似
的错误
TypeError: thread_chunking() takes 2 positional arguments but 3 were given
。
我尝试在目标方法中以 *args 形式接收,但它以元组形式给出,而内容仅位于其中。
我的代码如下,
thread_chunk=pandas.read_sql("some sql here")
....
thread_name= threading.Thread(target=self.thread_chunking,args=thread_chunk[0:100]))
那么如何在 python
中将 a 传递给线程中的目标函数
args
是目标调用的参数元组。
尝试将其传递为:
thread_name= threading.Thread(target=self.thread_chunking,args=(thread_chunk[0:100],))
看看有没有用...
Link 到文档:https://docs.python.org/2/library/threading.html#thread-objects
我正在实施一个多线程概念,它将大容量 <class 'pandas.core.frame.DataFrame'>
分成一些块。当我将它作为 args 发送到目标函数时,我收到类似
TypeError: thread_chunking() takes 2 positional arguments but 3 were given
。
我尝试在目标方法中以 *args 形式接收,但它以元组形式给出,而内容仅位于其中。
我的代码如下,
thread_chunk=pandas.read_sql("some sql here")
....
thread_name= threading.Thread(target=self.thread_chunking,args=thread_chunk[0:100]))
那么如何在 python
中将 a 传递给线程中的目标函数args
是目标调用的参数元组。
尝试将其传递为:
thread_name= threading.Thread(target=self.thread_chunking,args=(thread_chunk[0:100],))
看看有没有用...
Link 到文档:https://docs.python.org/2/library/threading.html#thread-objects