Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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 类型错误:';活页';跨excel合并数据时,对象不可调用_Python_Python 3.x_Xlrd_Xlwt - Fatal编程技术网

Python 类型错误:';活页';跨excel合并数据时,对象不可调用

Python 类型错误:';活页';跨excel合并数据时,对象不可调用,python,python-3.x,xlrd,xlwt,Python,Python 3.x,Xlrd,Xlwt,我现在正在为2 excel文件合并数据。我的方法是使用xlwt创建新的excel和相应的工作表。然后使用for循环写入新创建的excel文件。我的代码如下: #...... wbk = xlwt.Workbook() sheet_0 = wbk.add_sheet('A') sheet_1 = wbk.add_sheet('B') wbk.save(os.path.join(currentPath, gsheet.cell(gsr, 2).value) + Ful

我现在正在为2 excel文件合并数据。我的方法是使用
xlwt
创建新的excel和相应的工作表。然后使用for循环写入新创建的excel文件。我的代码如下:

#......
    wbk = xlwt.Workbook()
    sheet_0 = wbk.add_sheet('A')
    sheet_1 = wbk.add_sheet('B')
    wbk.save(os.path.join(currentPath, gsheet.cell(gsr, 2).value) + FullName + " " + time_now + ".xls")

    wkbk = xlrd.open_workbook(
        os.path.join(currentPath, gsheet.cell(gsr, 2).value) + FullName + " " + time_now + ".xls")
    wb_merge = copy(wkbk)
    wsheet_0 = wb_merge.get_sheet(0)
    wsheet_1 = wb_merge.get_sheet(1)

    workbook_merge_0 = xlrd.open_workbook(os.path.join(currentPath, filename0), formatting_info=True)
    sheet_merge_0 = workbook_merge_0.sheet_by_index(0)

    for r in range(0, total_row_0):
        for c in range(0, total_col_0):
            wsheet_1.write(r, c, sheet_merge_0(r, c).value)
#......
当我运行整个代码时,error show
TypeError:“Sheet”对象不可调用
,指向最后一行,即
wsheet\u 1.write(r,c,Sheet\u merge\u 0(r,c).value)


可以提供任何建议吗?提前谢谢

工作表\u merge\u 0
是一个
工作表
。你试图调用它,就好像它是一个函数一样。您可能想调用它的
单元格
方法,就像前面在同一代码中对其他工作表所做的那样?好吧,基本问题很明显:
sheet\u merge\u 0
是一个
sheet
,但您试图像函数一样访问它。查看
类文档;找到从工作表中获取特定单元格的正确语法。这个类应该有一个访问方法,或者你只需要括号而不是括号。谢谢!我被修改为
sheet\u merge\u 0.cell(r,c).value
,它工作得非常好!