问题描述
我有一个用openpyxl Cell对象初始化的python类。它是传统的单元格类,它接受Cell对象并读取Cell对象的某些属性并将其存储为自己的对象,
import openpyxl as oxl
class oxl_cell_objectclass(object):
def __init__(self,cell):
self.cell = cell
self.xl_column = cell.column
self.xl_row = cell.row
self.cell_value = cell.value
我该如何在python数据类中进行精简(在python 3.7 +中引入)。我尝试了下面显示的代码,它给了我一个找不到单元格的异常,
@dataclass
class oxl_cell_dataclass:
cell : oxl.cell.cell.Cell #openpyxl Cell object
xl_column : oxl.cell.cell.Cell.column = cell.column #default value for xl_column attribute
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)