import xlwt
book = xlwt.Workbook(encoding='utf-8',style_compression=0) # 創建excel文件
sheet = book.add_sheet('班級信息',cell_overwrite_ok=True) # 創建sheet
col = ('姓名','性別','年齡','班級') # 列名
for i in range(len(col)):
sheet.write(0,i,col[i]) # 寫入列名
datalist = ['jack','men','16','20601'] # 需要保存的數據
count = 0
count += 1
for i in range(len(datalist)):
sheet.write(count,i,datalist[i]) # 寫入數據
savepath = './招聘信息.xls'
book.save(savepath) # 保存