需要pandas, numpy, openxyl等库
import pandas as pd
##############读文件示例###################################
excelFile = "C:\Users\win10\Desktop\test.xlsx"
df = pd.read_excel(excelFile,sheet_name= "Sheet1")
nrows = df.shape[0]
ncols = df.columns.size
print(nrows)
print(ncols)
print(df.iloc[0,0])
##############写文件示例###################################
# stuID = [50101, 50102, 50103, 50104, 50105]
name = ['张三','李四','王五','孙甲','杨乙']
stuID = np.zeros(5)
Chinese = [96, 99, 93, 89, 90]
maths = [100, 99, 99, 92, 95]
English = [98, 98, 95, 90, 91]
data1 = {'学号': stuID, '姓名': name, '语文': Chinese, '数学': maths, '英语': English}
# data1 = {stuID, Chinese}
df2 = pd.DataFrame(data1)
df2.to_excel('C:\Users\win10\Desktop\test2.xlsx', sheet_name='Sheet1', index=False,header=True)