话不多说,直接上代码 import numpy as np import xlrd from math import exp # 读数据并求熵 path = u'E:/数据.xlsx' # 这里换成你自己的路径 hn, nc = 1, 0 # hn为表头行数,nc为表头列数 sheetname = u'Sheet1' def readexcel(hn, nc): data = xlrd.open_workbook(path) table = data.sheet_by_name(sheetname) nrows = table.nrows