使用python怎么读写修改Excel

  介绍

这期内容当中小编将会给大家带来有关使用python怎么读写修改Excel,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

0,安装模块

pip3  install  xlrd  xlwt  xlutils

1。写入excel

git: https://github.com/python-excel/xlwt/tree/master/examples

实现效果

使用python怎么读写修改excel“> </p> <p>上代码</p> <pre类=得到datetime  import  datetime      import  xlwt      时间=font0  xlwt.Font ()=#,font0.name  & # 39; Times  New 罗马# 39;,#,适用于字母或数字   时间=font0.name  & # 39;宋体& # 39;,,#,适用于中文,适配字体或者不指定字体才能体现出指定的颜色      #,font0.colour_index =, 1,, #,白色=#,font0.colour_index  2,, #,红色=#,font0.colour_index  3,, #,绿色=#,font0.colour_index  4,, #,蓝色   5 #,font0.colour_index =,,, #,黄色   6 #,font0.colour_index =,,, #,紫色   7 #,font0.colour_index =,,, #,青色   8 #,font0.colour_index =,,, #,黑色,比默认加黑,不加粗   时间=font0.colour_index  4,, #,蓝色   font0.bold =,真的      时间=style0  xlwt.XFStyle ()   style0.font =font0      #,创建样式对象:日期格式   时间=style1  xlwt.XFStyle ()   时间=style1.num_format_str  & # 39; YYYY-MM-DD& # 39;      #,创建样式对象:字体居中对齐   时间=style2  xlwt.XFStyle ()   时间=al  xlwt.Alignment ()   时间=al.horz  0 x02  #,设置水平居中   时间=al.vert  0 x01  #,设置垂直居中   style2.alignment =,      #,创建样式对象,设置日期格式与字体居中对齐   时间=style3  xlwt.XFStyle ()   时间=style3.num_format_str  & # 39; YYYY-MM-DD& # 39;   style3.alignment =,      #,创建样式对象,设置字体居中,且,设置字体颜色   时间=style4  xlwt.XFStyle ()   style4.alignment =,   style4.font =font0      时间=now_time  datetime.now () .strftime (& # 39; Y % - % - % d  % x # 39;)   date_time =, datetime.now () .strftime (& # 39; Y - % - % d % # 39;)      #,创建表格   时间=wb  xlwt.Workbook ()      #,新建一个名为,Score  Sheet 的表单页   时间=score_sheet  wb.add_sheet (& # 39; Score 表# 39;)      #,新建一个名为,Record  Test  Sheet 的表单页   时间=record_test_sheet  wb.add_sheet (& # 39; Record  Test 表# 39;)      #,1,写入,Score  Sheet 表单   #,设置,表头,,第一个参数是行,第二个参数是列   score_sheet.write(0, 0, & # 39;时间& # 39;,,style2)   score_sheet.write(0, 1, & # 39;班级& # 39;,,style2)   score_sheet.write(0,, 2,, & # 39;姓名& # 39;,,style2)   score_sheet.write(0,, 3,, & # 39;语文& # 39;,,style2)   score_sheet.write(0,, 4, & # 39;数学& # 39;,,style2)   score_sheet.write(0,, 5日,& # 39;英语& # 39;,,style2)   score_sheet.write(0,, 6日,& # 39;理综& # 39;,,style2)   score_sheet.write(0,, 7日,& # 39;总分& # 39;,,style4)      #,按照位置添加数据   score_sheet.write(0, 1,还以为;datetime.now(),,摆在)   score_sheet.write(1, 1, & # 39;高三三班& # 39;,,style2)   score_sheet.write(1,, 2,, & # 39;桑岩& # 39;,,style2)   score_sheet.write (1,, 3,, 132,, style2)   score_sheet.write(1, 4, 150年,style2)   score_sheet.write(1, 5日,140年,style2)   score_sheet.write(1), 6日,290年,style2)   score_sheet.write(1,, 7日,xlwt.Formula (“D2 + E2 + F2 + G2"),, style2)      score_sheet.write (2,, 0,, datetime.now(),,摆在)   score_sheet.write(2, 1, & # 39;高三三班& # 39;,,style2)   score_sheet.write(2, 2, & # 39;项天骐& # 39;,,style2)   score_sheet.write(140年,2,,3,,style2)   score_sheet.write(2, 4, 150年,style2)   score_sheet.write(2, 5, 132年,style2)   score_sheet.write(2, 6日,280年,style2)   score_sheet.write (2,, 7, xlwt.Formula (“D3 + E3 + F3 + G3"),, style2)      score_sheet.write (3,, 0,, datetime.now(),,摆在)   score_sheet.write(3,, 1,, & # 39;高三三班& # 39;,,style2)   score_sheet.write(3,, 2,, & # 39;向淮南& # 39;,,style2)   score_sheet.write (3,, 3,, 135,, style2)   score_sheet.write (3,, 4,, 150,, style2)   score_sheet.write(145年,3,5,,style2)   score_sheet.write(3, 6日,270年,style2)   score_sheet.write(3, 7日,xlwt.Formula (“D4 + E4 + F4 + G4"),, style2)         #,2,写入,Record  Test  Sheet 表单   record_test_sheet.write(0, 0, & # 39;时间& # 39;)   record_test_sheet.write(0, 1, & # 39;学科& # 39;,,style1)   record_test_sheet.write(0,, 2,, & # 39;成绩& # 39;,,style1)   record_test_sheet.write(0, 1,还以为;datetime.now (),, style1)   record_test_sheet.write(1, 1, & # 39;语文& # 39;,,style2)   record_test_sheet.write (1,, 2,, 80)   record_test_sheet.write (2,, 0,, datetime.now(),,摆在)   record_test_sheet.write(2, 1, & # 39;数学& # 39;,,style2)   record_test_sheet.write (2, 2, 99)   record_test_sheet.write (3,, 0,, now_time,, style2)   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

使用python怎么读写修改Excel