【金秋打卡】第19天+Python办公自动化

2022/11/13 4:23:54

本文主要是介绍【金秋打卡】第19天+Python办公自动化,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  • 文章标题:【金秋打卡】第19天+Python办公自动化

  • 第一模块: 学习课程名称:Python办公自动化;章节名称(序号):3-9基于xlrd模块实现考试数据库管理;讲师姓名:离岛

  • 第二模块: 课程内容(内容概述):

    Excel导入试题到数据库操作步骤

    1.通过Xlrd木块读取Excel数据;

    2.通过Pymysql模块链接数据库;

    3.组装数据、执行插入操作;

    4.关闭数据库连接。

  • 第三模块: 最终的解决思路

    https://img1.sycdn.imooc.com/636ef526000100ce09650951.jpg

xlrd
date=xlrd.open_workbook()
sheet=date.sheet_by_index()questionlist=[]questioni (sheet.nrows):
    i>:
        obj=question()obj.subject=sheet.cell(i,).valueobj.subjecttype= sheet.cell(i,).value  obj.optionA = sheet.cell(i, ).value  obj.optionB= sheet.cell(i, ).value  obj.optionC = sheet.cell(i, ).value  obj.optionD = sheet.cell(i, ).value  obj.score = sheet.cell(i, ).value  obj.answer = sheet.cell(i, ).value  questionlist.append(obj)

(questionlist)mysqlhelper *
db=dbhelper(,,,,)
sql=val=[]item questionlist:
    val.append(item.subject,item.subjecttype,item.optionA,item.optionB,item.optionC,item.optionD,item.score,item.answer)
(val)
db.executemanydate(sql,val)



这篇关于【金秋打卡】第19天+Python办公自动化的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程