简体   繁体   English

在两个函数之间传递数据。 '布尔'对象不可调用

[英]Passing data between two functions. 'bool' object is not callable

I am trying to make desktop-app for my science work. 我正在尝试为我的科学工作创建桌面应用程序。

I have a function that processes the data, and return me 3 list objects. 我有一个处理数据的函数,并返回3个列表对象。 code

  def process(self):
    file_location = "'/Users/Graygood/Desktop/Science\ comput/Application/Sheet.xlsx'"
    sample = pd.read_excel('Sheet.xlsx', sheetname ='Sheet1', index_col=None, na_values=['NA'])

    list_of_index = []
    for i in range(len(sample.columns)):
        sample2 = sample.iloc[:, lambda sample: [i]]
        sample2 = sample2.columns[0]
        list_of_index.append(sample2)
    list_of_index   

    ...        ...        ...        ...        ...
    ...        ...        ...        ...        ...

    ...        ...        ...        ...        ...
    return fulllist, fulllist_percent, fulllist_click



def saveSample(self, process):
    fulllist, fulllist_percent, fulllist_click = process(self)
    workbook = xlsxwriter.Workbook('lul.xlsx')
    worksheet1 = workbook.add_worksheet()
    worksheet2 = workbook.add_worksheet()
    worksheet3 = workbook.add_worksheet()


    row = 0

    for col, data in enumerate(fulllist):
        worksheet1.write_column(row, col, data)
    for col, data in enumerate(fulllist_percent):
        worksheet2.write_column(row, col, data)   
    for col, data in enumerate(fulllist_click):
        worksheet3.write_column(row, col, data)      


    workbook.close()

But when I try to get this lists, i get a "'bool' object is not callable" error. 但是,当我尝试获取此列表时,出现“'bool'对象不可调用”错误。 error 错误

I'm pretty new to python, so I might make some stupid mistake, that i do not see 我是python的新手,所以我可能会犯一些愚蠢的错误,我看不到

Firstly, when asking a question you need to give all the relevant information. 首先,在提问时,您需要提供所有相关信息。 Rather than saying you use a button click to call this function, you need to show the actual code that assigns the button to the function. 与其说您使用按钮单击来调用此功能,不如显示将按钮分配给该功能的实际代码。

In this case it is clear what the problem is. 在这种情况下,很清楚问题出在哪里。 You are confused between two things called "process": one is a parameter to the function, which is presumably a boolean value, and the other is a method on the class. 您对称为“过程”的两件事感到困惑:一个是函数的参数,它大概是布尔值,而另一个是类上的方法。

To call a method you always need to refer to it via the instance, which inside another method is available via self . 要调用方法,您始终需要通过实例引用它,而在另一个方法内部可以通过self来引用它。 Note, however, you do not pass self as a paramater. 但是请注意,您不会将self作为参数。

fulllist, fulllist_percent, fulllist_click = self.process()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM