模块功能
Python语言中,读写Excel的扩展工具--模块xlrd、xlwt:
xlrd意为:xls文件read库,只能读,可以实现指定表单、指定单元格的读取;
xlwt意为:xls文件write库,只能写,可以实现指定表单、指定单元格的写入;
发展历史
#-*-coding:utf-8-*-
import
xlrd
def
open_excel(
file
=
'file.xls'
):
try
:
data
=
xlrd.open_workbook(
file
)
return
data
except
Exception,e:
str
(e)
#根据索引获取Excel表格中的数据参数:file:Excel文件路径colname_index:表头列名所在行的所以,by_index:表的索引
def
excel_table_byindex(
file
=
'file.xls'
,colname_index
=
0
,by_index
=
0
):
data
=
open_excel(
file
)
table
=
data.sheets()[by_index]
nrows
=
table.nrows
#行数
ncols
=
table.ncols
#列数
colnames
=
table.row_values(colname_index)
#某一行数据
res_list
=
[]
for
rownum
in
range
(
1
,nrows):
row
=
table.row_values(rownum)
if
row:
app
=
{}
for
i
in
range
(
len
(colnames)):
app[colnames[i]]
=
row[i]
res_list.append(app)
return
res_list
#根据名称获取Excel表格中的数据参数:file:Excel文件路径colname_index:表头列名所在行的所以,by_name:Sheet1名称
def
excel_table_byname(
file
=
'file.xls'
,colname_index
=
0
,by_name
=
u
'Sheet1'
):
data
=
open_excel(
file
)
table
=
data.sheet_by_name(by_name)
nrows
=
table.nrows
#行数
colnames
=
table.row_values(colname_index)
#某一行数据
res_list
=
[]
for
rownum
in
range
(
1
,nrows):
row
=
table.row_values(rownum)
if
row:
app
=
{}
for
i
in
range
(
len
(colnames)):
app[colnames[i]]
=
row[i]
res_list.append(app)
return
res_list
def
main():
tables
=
excel_table_byindex()
for
row
in
tables:
row
tables
=
excel_table_byname()
for
row
in
tables:
row
if
__name__
=
=
"__main__"
:
main()
importxlwt
fromdatetimeimportdatetime
font0
=
xlwt.Font()
font0.name
=
'TimesNewRoman'
font0.colour_index
=
2
font0.bold
=
True
style0
=
xlwt.XFStyle()
style0.font
=
font0
style1
=
xlwt.XFStyle()
style1.num_format_str
=
'D-MMM-YY'
wb
=
xlwt.Workbook()
ws
=
wb.add_sheet(
'ATestSheet'
)
ws.write(
0
,
0
,
'Test'
,style0)
ws.write(
1
,
0
,datetime.now(),style1)
ws.write(
2
,
0
,
1
)
ws.write(
2
,
1
,
1
)
ws.write(
2
,
2
,xlwt.Formula(
"A3+B3"
))
wb.save(
'example.xls'
)
idea控制台中文乱码解决办法一、file --->Settings —>Editor —>File Encodings二、Help —> Edit Custom VM Options三、在Tomcat上添加四、Tomcat安装目录下的conf配置logging.properties的文件,如下图位置改为DBK五、在Idea的安装目录bin:打开如下两个,在其中添加六、在pom.xml文件中添加到这里就结束了,如果有遗漏的地方,可以告诉我,我添上。希望可以给朋友们带来帮助。一、f_idea 2023.2\bin" -dfile.encoding=utf-8
Eric S. Raymond五部曲之The Magic Cauldron魔法大锅炉—— 前言、目录Eric Raymond (1999年六月)[AKA]rover HansB iasc等翻译 -------------------------------------------------------------------------------- 本文分析了正在不断发展的开放_约定价值和销售价值区别
表顺序:raw - mangle - nat - filterFILTER:INPUT链 处理来自外部的数据 OUTPUT链 处理向外发送的数据 FORWARD链 将数据转发到本机的其他网卡设备上NAT: PREROUTING链 处理刚到达本机并在路由转发前的数据包,常用于DNAT POSTROUTING链 处理即将离开本机的数据包,常用于SNAT OUTPUT链 处理本机产生的数据包MANGLE: 用于指定如何处理数据包。能改变TCP头中的QoS..._k8siptables
本教程为本人在看了许多前辈有关WineQQ的文章后整理出来的,只保留最必须的步骤,略去多余步骤。到目前为止,关于WineQQ的安装的文章我已经写了3篇了,分别是ukylin论坛中的WineQQ7.8、WineQQ8.9.1和这次的WineQQ8.9.2。按理来说同一个类型的文章没有必要写这么多篇,但是本着分享和探索的原则,我还是写了,并且未来还会写很多。每一篇文章我都基于当时的环境进行了细致的测试..._wine8 qq
目录mkdir -p /opt/ftpData用户创建一个 FTP 用户组,用于存放 FTP 用户。# groupadd ftpgroup创建 FTP 用户登入时的主目录的父目录# cd /home/# pwd/home# mkdir ftpusers# cd ftpusers/# pwd/home/ftpusers创建一个 FTP 用户创建一个 FTP 用户,指定登入时的主目录并加入 ftpgroup 组:# useradd -d _3. 创建 ftp 用户登入时的主目录的父目录
Qt控件--QComboBoxQComboBox属性editable : boolcurrentText : QStringcurrentIndexmaxVisibleItems : intmaxCount : intinsertPolicy : InsertPolicysizeAdjustPolicy : SizeAdjustPolicyminimumContentsLength : inticonSize : QSizeduplicatesEnabled : boolframe : boolmodelC_duplicatesenabled
本环境为AWS EC2 instance Amazon Linux :1、安装所需软件yuminstallmakegccgmp-develbisonflexlsofwgetlibpcap-develppppolicycoreutils2、下载、安装、配置openswan[root@redis01-jp~]#wget--no-check-certi..._l2tp共享密钥怎么获取
System.Security.Cryptography.CryptographicException: 系统找不到指定的文件X509Certificate2 tempSignCert = new X509Certificate2(证书, "密码");本地调试成功,发布到远程云服务器失败,提示找不到指定文件。File.Exists(Server.MapPath("证书"))判断文件
http://blog.csdn.net/hailong0715/article/details/51751208装饰器模式(DECRATOR):为了实现动态的给对象添加职能,即从外部给对象添加相关职能。可以这样理解,比如说一个Person类,该类的操作有能吃、能睡、能跑、但假如随着人类的进化,某一天Person能飞了,能在水里游了等等,按照一般的写法是修改Person这个类,
我用CCS v5.0打开已经编译工程文件时,显示错误“The project description file (.project) for 'test_ad' is missing. This file contains important information about the project. The project will not function properly until
CSS盒子模型引用官方的话,所有html元素可以看作盒子,CSS盒模型本质是一个盒子,封装周围的HTML元素,包括外边距,边框,内边距和内容W3C盒子模型(标准盒子模型)一般来讲我们在CSS中定义的width和height都是设置content的宽高,而盒子的总宽高 = content宽高 + 2 * margin + 2 * padding + 2 * borderIE盒子模型(怪异盒子模型)相对于标准盒子模型,css中设置的宽高属性就盒子而言是指content+padding+border的