标签:获取 pytho upd exce class python value work name
操作承接上面数据库操作的基础,好了,直接上代码
# Excel导入数据库处理 tables = load_workbook(filename=‘Database/stud.xlsx‘) # 获取表内容 data = tables.worksheets[0] rows = data.max_row cols = data.max_column sql = ‘insert into stu (name, age) values (?, ?)‘ xl_data = [] for rx in range(2, rows+1): for cx in range(1,cols+1): xl_data.append(str(data.cell(row=rx, column=cx).value)) ob = [(xl_data[0], xl_data[1])] T = db.execute_update(sql, ob) if T: print(‘插入成功!‘) else: print(‘插入失败!‘) xl_data = []
这样就可以进行简单的写入咯
标签:获取 pytho upd exce class python value work name
原文地址:https://www.cnblogs.com/pythoncoder/p/11031136.html