python - 为什么我在发送时会在方法中收到多个值作为python中的args
问题描述
我正在实现一个多线程概念,它将一个大块<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],))
看看有没有效果...
链接到文档:https ://docs.python.org/2/library/threading.html#thread-objects
推荐阅读
- css - 在图像上制作正方形?
- php - codeIgniter 中的错误滑块轮播 Boostrap
- c# - 按属性分组并在每个属性下列出从 sql 到 C#
- vue.js - vuex mapGetters 是否值得使用?
- c# - 我们可以用 C# Socket 创建 Windows 服务吗
- angular - Angular 6:无法加载动态表单
- sql - 通过将其与一组字符进行比较来替换文本中的关键字
- wpf - 如果附在下面,如何在 wpf c# 类我的 xmal 代码中检查 cehckbox 值
- javascript - 在嵌套数组中查找对象及其位置
- firebase - Firebase 功能:自定义身份验证端点