您的位置:首页 > 编程语言 > Python开发

Python excel 读写操作

2016-05-12 10:55 489 查看
1.下载python的excel依赖库

xlrd-0.9.4.tar.gz, xlwt-1.0.0.tar.gz

xlrd下载地址:http://download.csdn.net/detail/rock4you/9538298

xlwt下载地址:http://download.csdn.net/detail/rock4you/9539401

2.安装。

a.将xlrd-0.9.4.tar.gz解压到D盘根目录下,文件夹中的内容如下:



b.进入cmd,输入:

D:\


c.进入D盘根目录后,输入:

cd xlrd-0.9.4


d.进入解压后的文件夹中,输入:
setup.py install
安装完成。xlwt安装步骤与上述过程相同。

3.应用。

a.写文件

import xlwt

mydatasheet = xlwt.Workbook ()
sheet = mydatasheet.add_sheet('name') # name of the sheet
sheet.write(0,0,'python') # value of the unit
mydatasheet.save('test.xls') # save thefilename of the excel

b.读文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  excel python