在win7下python的xlrd和xlwt的安裝於應用

來源:互聯網
上載者:User

首先到http://pypi.python.org/pypi/xlwt 和http://pypi.python.org/pypi/xlrd下載xlwt-0.7.4.tar.gz和xlrd-0.7.7.tar.gz。

第二把下載的兩個.gz包解壓,如我把它們解壓到F:DOWNLOAD下。

在win7下開啟cmd,在命令列輸入F:,切換到F盤,再cd DOWNLOAD\xlrd-0.7.7,

最後 setup.py install.裝完了。xlwt同理。

應用

(1)xlrd

import xlrd

filename = 'E:\lianxi\protein.xls'   

data = xlrd.open-workbook(filename) 

sheetname = data.sheet_names()

sheet = data.sheet_by_index(0) 

rows = sheet.nrows

cols = sheet.ncols

for row in range(rows):

   value = sheet.row_values(row)

   print value

(2)xlwt

import xlwt

filename = xlwt.Workbook ()

sheet = filename.add_sheet('name')

sheet.write(0,0,'hao123')

filename.save('test.xls')

 

摘自:http://www.cnblogs.com/yanzhi123/archive/2012/04/16/2452214.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.