我正在尝试在 excel 中打开一列并将其单元格中的所有值移动到列表中。
def open_excel(col, excel_file):
open_file = openpyxl.load_workbook(excel_file)
sheet_object = open_file.get_sheet_names()[0]
cell_vals = []
col_num = column_index_from_string(start_col)
for cell in sheet_object.columns[col_num]:
cell_vals.append(str(cell.value))
在我运行之后,我得到了错误:
builtins.AttributeError: 'str' object has no attribute 'columns'
但我也已经导入了所有内容。
这是我导入的内容:
import openpyxl
from openpyxl.cell import get_column_letter, column_index_from_string
import numpy as np
import matplotlib.pyplot as plt