文章标题:【金秋打卡】第19天+Python办公自动化
第一模块: 学习课程名称:Python办公自动化;章节名称(序号):3-9基于xlrd模块实现考试数据库管理;讲师姓名:离岛
第二模块: 课程内容(内容概述):
Excel导入试题到数据库操作步骤
1.通过Xlrd木块读取Excel数据;
2.通过Pymysql模块链接数据库;
3.组装数据、执行插入操作;
4.关闭数据库连接。
第三模块: 最终的解决思路
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)
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評論
評論
共同學(xué)習(xí),寫下你的評論
評論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦