import os, shutil
from tkinter import * #tkinter stands for toolkit interface
from tkinter import filedialog
import re
import xlwings as xw
file_names = xw.Book(filedialog.askopenfilename())
file_names_sh = file_names.sheets['fe_0.85']
folder_source_train = filedialog.askdirectory()
train_destination = r'D:\Machine_learning\train/'
import numpy as np
numbers= re.compile(r'(\d+)')
def numerical_sort(value):
parts= numbers.split(value)
parts[1::2]= map(int, part[1::2])
return parts
def copy_range(start_col, start_row, end_col, end_row, sheet):
range_selected = []
for i in range(start_row, end_row + 1, 1):
row_selected = []
for j in range(start_col, end_col + 1, 1):
row_selected.append(sheet.cell(row = i, column = j).value)
range_selected.append(row_selected)
return range_selected
selectedRange_train = copy_range(1, 1, 2, 100, file_names_sh)
我遇到了像“Sheet”对象没有属性“cell”这样的错误。上面提到的代码中的“copy_range(~~)”似乎有问题。我应该添加什么?我不知道什么或如何解决它。请帮助我...
类型错误:
[1]: object has no attribute attr
通常指的是没有使用该名称实现任何特定方法的类,因为您的案例对象表没有在其上实现方法单元,您要使用的属性是 cells
根据源代码: cells 或旧版本的 xlwings 中存在特定属性