mysql 与 excel

来源:互联网 发布:java算法有哪些 编辑:程序博客网 时间:2024/05/22 10:53

mysql:http://www.cnblogs.com/W-Kr/p/5456810.html

conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', password='root', db='txj', charset='utf8')with conn.cursor() as cursor:    sql = "select * from free"    cursor.execute(sql)    # fetchall取出所有数据,fetchmany(5)取出前5条数据,fetchone()取出第一条数据    result = cursor.fetchall()conn.close()

excel:读:http://www.cnblogs.com/lhj588/archive/2012/01/06/2314181.html
写:http://www.jb51.net/article/77626.htm

import xlwtworkbook = xlwt.Workbook()sheet = workbook.add_sheet('sheet1', cell_overwrite_ok=True)# init excelsheet.write(0,1,'周一')sheet.write(0,1,'周二')sheet.write(0,1,'周三')sheet.write(0,1,'周四')sheet.write(0,1,'周五')workbook.save('free.xls')
0 0
原创粉丝点击