|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 康小泡 于 2017-11-9 11:14 编辑
- def student_information_write(num): #建立学生信息
- row=0 #行数
- col=0 #列数
- num=int(num)
- if os.path.isfile(Path+"/information.xls"):
- information_excel=xlrd.open_workbook(Path+"/information.xls",encoding="utf-8")#如果文件存在打开表格
- information_sheet=information_excel.sheet_by_name("information")
- else:
- information_excel=xlwt.orkbook(Path+"/information.xls")#如果文件,不存在新建表格
- information_sheet=information_excel.add_sheet("information")#建立信息sheet
- information_sheet.write(0,0,unicode("student name","utf-8"))# 存放学生姓名信息
- information_sheet.write(0,1,unicode("student age","utf-8"))# 存放学生成绩信息
- information_sheet.write(0,2,unicode("student score","utf-8")#存放学生年龄信息
-
- while(num!=0):
- name=name_list()
- age=age_list()
- score=score_list()
- information_sheet.write(row+1,col,unicode(name,"utf-8"))# 写入名字
- information_sheet.write(row+1,col+1,unicode(age,"utf-8"))#写入年龄
- information_sheet.write(row+1,col+2,unicode(score,"utf-8"))#写入成绩
- row+=1
- num-=1
-
- information_excel.close()
复制代码 |
|